From 714b4cfe863dfed31218b2c9ef4b0183d9675c5b Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Mon, 1 Jun 2020 23:28:55 +0700 Subject: [PATCH 01/12] :wrench: Init bundle configuration --- api/v1beta1/config_types.go | 8 + api/v1beta1/desiredcomponent_types.go | 3 + api/v1beta1/queue_types.go | 93 +++++++-- api/v1beta1/stablecomponent_types.go | 4 + api/v1beta1/zz_generated.deepcopy.go | 162 +++++++++++++-- ....samsahai.io_activepromotionhistories.yaml | 6 +- .../env.samsahai.io_activepromotions.yaml | 6 +- config/crds/env.samsahai.io_configs.yaml | 7 + .../env.samsahai.io_desiredcomponents.yaml | 2 + .../crds/env.samsahai.io_queuehistories.yaml | 39 +++- config/crds/env.samsahai.io_queues.yaml | 31 ++- .../env.samsahai.io_stablecomponents.yaml | 5 +- config/crds/env.samsahai.io_teams.yaml | 12 +- internal/config/controller.go | 16 ++ internal/configuration.go | 3 + internal/desiredcomponent/controller.go | 19 +- internal/queue/controller.go | 190 ++++++++++++------ internal/samsahai/internal_process.go | 27 ++- internal/samsahai/rpc.go | 1 + internal/staging/controller.go | 1 + internal/staging/image_missing.go | 3 + .../staging/testrunner/teamcity/testrunner.go | 2 +- 22 files changed, 523 insertions(+), 117 deletions(-) diff --git a/api/v1beta1/config_types.go b/api/v1beta1/config_types.go index eda4adc5..3ab71d02 100644 --- a/api/v1beta1/config_types.go +++ b/api/v1beta1/config_types.go @@ -56,6 +56,10 @@ type ComponentChart struct { Version string `json:"version,omitempty"` } +// ConfigBundles represents a group of component for each bundle +// to verify a group of components of a same bundle together in staging environment +type ConfigBundles map[string][]string + // ConfigStaging represents configuration about staging type ConfigStaging struct { // Deployment represents configuration about deploy @@ -280,6 +284,10 @@ type ConfigSpec struct { // Components represents all components that are managed Components []*Component `json:"components"` + // Bundles represents a group of component for each bundle + // +optional + Bundles ConfigBundles `json:"bundles,omitempty"` + // Staging represents configuration about staging Staging *ConfigStaging `json:"staging"` diff --git a/api/v1beta1/desiredcomponent_types.go b/api/v1beta1/desiredcomponent_types.go index b6a71628..eca3375f 100644 --- a/api/v1beta1/desiredcomponent_types.go +++ b/api/v1beta1/desiredcomponent_types.go @@ -25,6 +25,8 @@ type DesiredComponentSpec struct { Name string `json:"name"` Version string `json:"version"` Repository string `json:"repository"` + // +optional + Bundle string `json:"bundle,omitempty"` } // DesiredComponentStatus defines the observed state of DesiredComponent @@ -44,6 +46,7 @@ type DesiredComponent struct { Status DesiredComponentStatus `json:"status,omitempty"` } +// TODO: pohfy, unused? func (c *DesiredComponent) IsSame(d *DesiredComponent) bool { return c.Spec.Name == d.Spec.Name && c.Spec.Repository == d.Spec.Repository && diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 6be1911b..1f2009c7 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -80,11 +80,20 @@ const ( Finished QueueState = "finished" ) +// TODO: pohfy, name is bundle name // QueueSpec defines the desired state of Queue type QueueSpec struct { - // Name represents Component name + // Name represents a Component name or bundle name if exist Name string `json:"name"` + // Bundle represents a bundle name of component + // +optional + Bundle string `json:"bundle,omitempty"` + + // Components represents a list of components which are deployed + Components QueueComponents `json:"components"` + + // TODO: pohfy, remove here // Repository represents Docker image repository Repository string `json:"repository"` @@ -114,6 +123,19 @@ type Image struct { Tag string `json:"tag"` } +type QueueComponents []*QueueComponent + +type QueueComponent struct { + // Name represents Component name + Name string `json:"name"` + + // Repository represents Docker image repository + Repository string `json:"repository"` + + // Version represents Docker image tag version + Version string `json:"version"` +} + type QueueCondition struct { Type QueueConditionType `json:"type"` Status corev1.ConditionStatus `json:"status"` @@ -269,10 +291,32 @@ type Queue struct { Status QueueStatus `json:"status,omitempty"` } +// TODO: pohfy, updated func (q *Queue) IsSame(d *Queue) bool { - return q.Spec.Name == d.Spec.Name && - q.Spec.Repository == d.Spec.Repository && - q.Spec.Version == d.Spec.Version + if q.Spec.Name != d.Spec.Name { + return false + } + + if len(q.Spec.Components) != len(d.Spec.Components) { + return false + } + + // expect component already sorted + for i := range d.Spec.Components { + if q.Spec.Components[i].Name != d.Spec.Components[i].Name || + q.Spec.Components[i].Repository != d.Spec.Components[i].Repository || + q.Spec.Components[i].Version != d.Spec.Components[i].Version { + return false + } + } + //return q.Spec.Name == d.Spec.Name && + // q.Spec.Repository == d.Spec.Repository && + // q.Spec.Version == d.Spec.Version + return true +} + +func (q *Queue) IsInExistBundle(d *Queue) bool { + return q.Spec.Bundle != "" && q.Spec.Bundle == d.Spec.Bundle } func (q *Queue) SetState(state QueueState) { @@ -299,6 +343,17 @@ func (q *Queue) IsActivePromotionQueue() bool { q.Spec.Type == QueueTypeDemoteFromActive } +//func (q *Queue) UpdateComponentIfNotExist(d *Queue) string { +// q.Spec.Components.Sort() +// d.Spec.Components.Sort() +// +// for _, dcomp := range d.Spec.Components { +// for _, qcomp := range q.Spec.Components { +// if qcomp.Name != +// } +// } +//} + // GetEnvType returns environment type for connection based on Queue.Spec.Type func (q *Queue) GetEnvType() string { switch q.Spec.Type { @@ -337,7 +392,7 @@ func (ql *QueueList) TopQueueOrder() int { if len(ql.Items) == 0 { return 1 } - sort.Sort(ByNoOfOrder(ql.Items)) + sort.Sort(QueueByNoOfOrder(ql.Items)) return ql.Items[0].Spec.NoOfOrder - 1 } @@ -346,7 +401,7 @@ func (ql *QueueList) LastQueueOrder() int { if len(ql.Items) == 0 { return 1 } - sort.Sort(ByNoOfOrder(ql.Items)) + sort.Sort(QueueByNoOfOrder(ql.Items)) return ql.Items[len(ql.Items)-1].Spec.NoOfOrder + 1 } @@ -378,15 +433,15 @@ func (ql *QueueList) First() *Queue { return &ql.Items[0] } -// Sort sorts items +// Sort sorts queue items func (ql *QueueList) Sort() { - sort.Sort(ByNoOfOrder(ql.Items)) + sort.Sort(QueueByNoOfOrder(ql.Items)) } -type ByNoOfOrder []Queue +type QueueByNoOfOrder []Queue -func (q ByNoOfOrder) Len() int { return len(q) } -func (q ByNoOfOrder) Less(i, j int) bool { +func (q QueueByNoOfOrder) Len() int { return len(q) } +func (q QueueByNoOfOrder) Less(i, j int) bool { now := metav1.Now() if q[i].Spec.NoOfOrder == q[j].Spec.NoOfOrder { @@ -417,7 +472,21 @@ func (q ByNoOfOrder) Less(i, j int) bool { return q[i].Spec.NoOfOrder < q[j].Spec.NoOfOrder } -func (q ByNoOfOrder) Swap(i, j int) { q[i], q[j] = q[j], q[i] } +func (q QueueByNoOfOrder) Swap(i, j int) { q[i], q[j] = q[j], q[i] } + +// Sort sorts component items +func (qc QueueComponents) Sort() { + sort.Sort(ComponentByName(qc)) +} + +type ComponentByName []*QueueComponent + +func (q ComponentByName) Len() int { return len(q) } +func (q ComponentByName) Less(i, j int) bool { + return q[i].Name < q[j].Name +} + +func (q ComponentByName) Swap(i, j int) { q[i], q[j] = q[j], q[i] } func init() { SchemeBuilder.Register(&Queue{}, &QueueList{}) diff --git a/api/v1beta1/stablecomponent_types.go b/api/v1beta1/stablecomponent_types.go index dc1ad25c..a9e45239 100644 --- a/api/v1beta1/stablecomponent_types.go +++ b/api/v1beta1/stablecomponent_types.go @@ -20,6 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// TODO: pohfy, updated // StableComponentSpec defines the desired state of StableComponent type StableComponentSpec struct { // Name represents Component name @@ -31,6 +32,9 @@ type StableComponentSpec struct { // Version represents Docker image tag version Version string `json:"version"` + // +optional + Bundle string `json:"bundle,omitempty"` + // UpdatedBy represents a person who updated the StableComponent // +optional UpdatedBy string `json:"updatedBy,omitempty"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 43e08511..710c7032 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -289,27 +289,6 @@ func (in *ActivePromotionStatus) DeepCopy() *ActivePromotionStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in ByNoOfOrder) DeepCopyInto(out *ByNoOfOrder) { - { - in := &in - *out = make(ByNoOfOrder, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ByNoOfOrder. -func (in ByNoOfOrder) DeepCopy() ByNoOfOrder { - if in == nil { - return nil - } - out := new(ByNoOfOrder) - in.DeepCopyInto(out) - return *out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in ChartValuesURLs) DeepCopyInto(out *ChartValuesURLs) { { @@ -398,6 +377,31 @@ func (in *Component) DeepCopy() *Component { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ComponentByName) DeepCopyInto(out *ComponentByName) { + { + in := &in + *out = make(ComponentByName, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(QueueComponent) + **out = **in + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentByName. +func (in ComponentByName) DeepCopy() ComponentByName { + if in == nil { + return nil + } + out := new(ComponentByName) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ComponentChart) DeepCopyInto(out *ComponentChart) { *out = *in @@ -484,6 +488,35 @@ func (in *ConfigActivePromotion) DeepCopy() *ConfigActivePromotion { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ConfigBundles) DeepCopyInto(out *ConfigBundles) { + { + in := &in + *out = make(ConfigBundles, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigBundles. +func (in ConfigBundles) DeepCopy() ConfigBundles { + if in == nil { + return nil + } + out := new(ConfigBundles) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConfigComponentUpgrade) DeepCopyInto(out *ConfigComponentUpgrade) { *out = *in @@ -612,6 +645,21 @@ func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) { } } } + if in.Bundles != nil { + in, out := &in.Bundles, &out.Bundles + *out = make(ConfigBundles, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } if in.Staging != nil { in, out := &in.Staging, &out.Staging *out = new(ConfigStaging) @@ -1039,6 +1087,67 @@ func (in *Queue) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in QueueByNoOfOrder) DeepCopyInto(out *QueueByNoOfOrder) { + { + in := &in + *out = make(QueueByNoOfOrder, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueByNoOfOrder. +func (in QueueByNoOfOrder) DeepCopy() QueueByNoOfOrder { + if in == nil { + return nil + } + out := new(QueueByNoOfOrder) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *QueueComponent) DeepCopyInto(out *QueueComponent) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueComponent. +func (in *QueueComponent) DeepCopy() *QueueComponent { + if in == nil { + return nil + } + out := new(QueueComponent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in QueueComponents) DeepCopyInto(out *QueueComponents) { + { + in := &in + *out = make(QueueComponents, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(QueueComponent) + **out = **in + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueComponents. +func (in QueueComponents) DeepCopy() QueueComponents { + if in == nil { + return nil + } + out := new(QueueComponents) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *QueueCondition) DeepCopyInto(out *QueueCondition) { *out = *in @@ -1217,6 +1326,17 @@ func (in *QueueList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *QueueSpec) DeepCopyInto(out *QueueSpec) { *out = *in + if in.Components != nil { + in, out := &in.Components, &out.Components + *out = make(QueueComponents, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(QueueComponent) + **out = **in + } + } + } if in.NextProcessAt != nil { in, out := &in.NextProcessAt, &out.NextProcessAt *out = (*in).DeepCopy() diff --git a/config/crds/env.samsahai.io_activepromotionhistories.yaml b/config/crds/env.samsahai.io_activepromotionhistories.yaml index 51ab3d0d..b3bc5f70 100644 --- a/config/crds/env.samsahai.io_activepromotionhistories.yaml +++ b/config/crds/env.samsahai.io_activepromotionhistories.yaml @@ -85,9 +85,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state - of StableComponent + description: 'TODO: pohfy, updated StableComponentSpec + defines the desired state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_activepromotions.yaml b/config/crds/env.samsahai.io_activepromotions.yaml index ca3069ce..0705caac 100644 --- a/config/crds/env.samsahai.io_activepromotions.yaml +++ b/config/crds/env.samsahai.io_activepromotions.yaml @@ -62,9 +62,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state of - StableComponent + description: 'TODO: pohfy, updated StableComponentSpec defines + the desired state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_configs.yaml b/config/crds/env.samsahai.io_configs.yaml index 49537ed0..658dd36d 100644 --- a/config/crds/env.samsahai.io_configs.yaml +++ b/config/crds/env.samsahai.io_configs.yaml @@ -113,6 +113,13 @@ spec: required: - deployment type: object + bundles: + additionalProperties: + items: + type: string + type: array + description: Bundles represents a group of component for each bundle + type: object components: description: Components represents all components that are managed items: diff --git a/config/crds/env.samsahai.io_desiredcomponents.yaml b/config/crds/env.samsahai.io_desiredcomponents.yaml index 6cd4f40d..44ffac44 100644 --- a/config/crds/env.samsahai.io_desiredcomponents.yaml +++ b/config/crds/env.samsahai.io_desiredcomponents.yaml @@ -34,6 +34,8 @@ spec: spec: description: DesiredComponentSpec defines the desired state of DesiredComponent properties: + bundle: + type: string name: type: string repository: diff --git a/config/crds/env.samsahai.io_queuehistories.yaml b/config/crds/env.samsahai.io_queuehistories.yaml index f70fd06c..d810c469 100644 --- a/config/crds/env.samsahai.io_queuehistories.yaml +++ b/config/crds/env.samsahai.io_queuehistories.yaml @@ -63,10 +63,35 @@ spec: metadata: type: object spec: - description: QueueSpec defines the desired state of Queue + description: 'TODO: pohfy, name is bundle name QueueSpec defines + the desired state of Queue' properties: + bundle: + description: Bundle represents a bundle name of component + type: string + components: + description: Components represents a list of components which + are deployed + items: + properties: + name: + description: Name represents Component name + type: string + repository: + description: Repository represents Docker image repository + type: string + version: + description: Version represents Docker image tag version + type: string + required: + - name + - repository + - version + type: object + type: array name: - description: Name represents Component name + description: Name represents a Component name or bundle name + if exist type: string nextProcessAt: description: NextProcessAt represents time to wait for process @@ -82,7 +107,8 @@ spec: has been tested type: integer repository: - description: Repository represents Docker image repository + description: 'TODO: pohfy, remove here Repository represents + Docker image repository' type: string teamName: description: TeamName represents team owner of the queue @@ -94,6 +120,7 @@ spec: description: Version represents Docker image tag version type: string required: + - components - name - noOfOrder - repository @@ -224,9 +251,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state of - StableComponent + description: 'TODO: pohfy, updated StableComponentSpec defines + the desired state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_queues.yaml b/config/crds/env.samsahai.io_queues.yaml index 58b66aaa..058a0c76 100644 --- a/config/crds/env.samsahai.io_queues.yaml +++ b/config/crds/env.samsahai.io_queues.yaml @@ -32,10 +32,33 @@ spec: metadata: type: object spec: - description: QueueSpec defines the desired state of Queue + description: 'TODO: pohfy, name is bundle name QueueSpec defines the desired + state of Queue' properties: + bundle: + description: Bundle represents a bundle name of component + type: string + components: + description: Components represents a list of components which are deployed + items: + properties: + name: + description: Name represents Component name + type: string + repository: + description: Repository represents Docker image repository + type: string + version: + description: Version represents Docker image tag version + type: string + required: + - name + - repository + - version + type: object + type: array name: - description: Name represents Component name + description: Name represents a Component name or bundle name if exist type: string nextProcessAt: description: NextProcessAt represents time to wait for process this @@ -51,7 +74,8 @@ spec: tested type: integer repository: - description: Repository represents Docker image repository + description: 'TODO: pohfy, remove here Repository represents Docker + image repository' type: string teamName: description: TeamName represents team owner of the queue @@ -63,6 +87,7 @@ spec: description: Version represents Docker image tag version type: string required: + - components - name - noOfOrder - repository diff --git a/config/crds/env.samsahai.io_stablecomponents.yaml b/config/crds/env.samsahai.io_stablecomponents.yaml index b8c6c806..7d5cad39 100644 --- a/config/crds/env.samsahai.io_stablecomponents.yaml +++ b/config/crds/env.samsahai.io_stablecomponents.yaml @@ -32,8 +32,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state of StableComponent + description: 'TODO: pohfy, updated StableComponentSpec defines the desired + state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_teams.yaml b/config/crds/env.samsahai.io_teams.yaml index c797e5a2..375d370e 100644 --- a/config/crds/env.samsahai.io_teams.yaml +++ b/config/crds/env.samsahai.io_teams.yaml @@ -158,9 +158,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state of - StableComponent + description: 'TODO: pohfy, updated StableComponentSpec defines + the desired state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string @@ -251,9 +253,11 @@ spec: metadata: type: object spec: - description: StableComponentSpec defines the desired state of - StableComponent + description: 'TODO: pohfy, updated StableComponentSpec defines + the desired state of StableComponent' properties: + bundle: + type: string name: description: Name represents Component name type: string diff --git a/internal/config/controller.go b/internal/config/controller.go index 63c6c2d4..35b787a0 100644 --- a/internal/config/controller.go +++ b/internal/config/controller.go @@ -135,6 +135,22 @@ func (c *controller) GetParentComponents(configName string) (map[string]*s2hv1be return filteredComps, nil } +// TODO: pohfy, fix mock +// GetParentComponents returns components that doesn't have parent (nil Parent) +func (c *controller) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + //config, err := c.Get(configName) + //if err != nil { + // logger.Error(err, "cannot get Config", "name", configName) + // return s2hv1beta1.ConfigBundles{}, err + //} + + //config.Spec. + + return s2hv1beta1.ConfigBundles{ + "db": []string{"mariadb", "redis"}, + }, nil +} + // Update updates Config CRD func (c *controller) Update(config *s2hv1beta1.Config) error { if err := c.client.Update(context.TODO(), config); err != nil { diff --git a/internal/configuration.go b/internal/configuration.go index 7f25da21..bf70a666 100644 --- a/internal/configuration.go +++ b/internal/configuration.go @@ -14,6 +14,9 @@ type ConfigController interface { // GetParentComponents returns components that doesn't have parent (nil Parent) GetParentComponents(configName string) (map[string]*s2hv1beta1.Component, error) + // GetBundles returns a group of components for each bundle + GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) + // Update updates Config CRD Update(config *s2hv1beta1.Config) error diff --git a/internal/desiredcomponent/controller.go b/internal/desiredcomponent/controller.go index b6a75a89..f9c97b85 100644 --- a/internal/desiredcomponent/controller.go +++ b/internal/desiredcomponent/controller.go @@ -111,11 +111,6 @@ func (c *controller) Reconcile(req reconcile.Request) (reconcile.Result, error) } logger.Debug(fmt.Sprintf("add %s (%s:%s) to queue", comp.Spec.Name, comp.Spec.Repository, comp.Spec.Version)) - q := queue.NewUpgradeQueue(c.teamName, req.Namespace, comp.Spec.Name, comp.Spec.Repository, comp.Spec.Version) - err = c.queueCtrl.Add(q) - if err != nil { - return reconcile.Result{}, err - } headers := make(http.Header) headers.Set(internal.SamsahaiAuthHeader, c.authToken) @@ -124,6 +119,20 @@ func (c *controller) Reconcile(req reconcile.Request) (reconcile.Result, error) logger.Error(err, "cannot set request header") } + // TODO: pohfy, get bundle config + comps := []*s2hv1beta1.QueueComponent{ + { + Name: comp.Spec.Name, + Repository: comp.Spec.Repository, + Version: comp.Spec.Version, + }, + } + q := queue.NewUpgradeQueue(c.teamName, req.Namespace, comp.Spec.Name, comp.Spec.Bundle, comps) + err = c.queueCtrl.Add(q) + if err != nil { + return reconcile.Result{}, err + } + rpcComp := &samsahairpc.ComponentUpgrade{ Name: q.Spec.Name, Namespace: q.Namespace, diff --git a/internal/queue/controller.go b/internal/queue/controller.go index ce9fd6d1..a059eafa 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -10,7 +10,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/agoda-com/samsahai/api/v1beta1" + s2hv1beta1 "github.com/agoda-com/samsahai/api/v1beta1" "github.com/agoda-com/samsahai/internal" s2hlog "github.com/agoda-com/samsahai/internal/log" ) @@ -26,24 +26,28 @@ type controller struct { var _ internal.QueueController = &controller{} -func NewUpgradeQueue(teamName, namespace, name, repository, version string) *v1beta1.Queue { +func NewUpgradeQueue(teamName, namespace, name, bundle string, comps []*s2hv1beta1.QueueComponent) *s2hv1beta1.Queue { qLabels := internal.GetDefaultLabels(teamName) qLabels["app"] = name qLabels["component"] = name - return &v1beta1.Queue{ + return &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Labels: qLabels, }, - Spec: v1beta1.QueueSpec{ + Spec: s2hv1beta1.QueueSpec{ Name: name, TeamName: teamName, - Repository: repository, - Version: version, - Type: v1beta1.QueueTypeUpgrade, + Bundle: bundle, + Components: comps, + // TODO: pohfy, start remove here + //Repository: repository, + //Version: version, + // TODO: pohfy, end remove here + Type: s2hv1beta1.QueueTypeUpgrade, }, - Status: v1beta1.QueueStatus{}, + Status: s2hv1beta1.QueueStatus{}, } } @@ -56,11 +60,11 @@ func New(ns string, runtimeClient client.Client) internal.QueueController { return c } -func (c *controller) Add(q *v1beta1.Queue) error { +func (c *controller) Add(q *s2hv1beta1.Queue) error { return c.add(context.TODO(), q, false) } -func (c *controller) AddTop(q *v1beta1.Queue) error { +func (c *controller) AddTop(q *s2hv1beta1.Queue) error { return c.add(context.TODO(), q, true) } @@ -73,7 +77,7 @@ func (c *controller) Size() int { return len(list.Items) } -func (c *controller) First() (*v1beta1.Queue, error) { +func (c *controller) First() (*s2hv1beta1.Queue, error) { list, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -97,16 +101,17 @@ func (c *controller) First() (*v1beta1.Queue, error) { return nil, nil } -func (c *controller) Remove(q *v1beta1.Queue) error { +func (c *controller) Remove(q *s2hv1beta1.Queue) error { return c.client.Delete(context.TODO(), q) } func (c *controller) RemoveAllQueues() error { - return c.client.DeleteAllOf(context.TODO(), &v1beta1.Queue{}, client.InNamespace(c.namespace)) + return c.client.DeleteAllOf(context.TODO(), &s2hv1beta1.Queue{}, client.InNamespace(c.namespace)) } -func (c *controller) add(ctx context.Context, queue *v1beta1.Queue, atTop bool) error { +// TODO: pohfy, check bundle and add to group instead +func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop bool) error { queueList, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -119,9 +124,18 @@ func (c *controller) add(ctx context.Context, queue *v1beta1.Queue, atTop bool) return nil } - pQueue := &v1beta1.Queue{} + bundleQueue := &s2hv1beta1.Queue{} + pQueue := &s2hv1beta1.Queue{} isAlreadyInQueue := false + isAlreadyInBundle := false for i, q := range queueList.Items { + if q.IsInExistBundle(queue) { + isAlreadyInBundle = true + bundleQueue = &queueList.Items[i] + break + } + + // TODO: pohfy, need to be updated if q.IsSame(queue) { isAlreadyInQueue = true pQueue = &queueList.Items[i] @@ -131,9 +145,8 @@ func (c *controller) add(ctx context.Context, queue *v1beta1.Queue, atTop bool) // remove duplicate component removingList := c.removeSimilar(queue, queueList) - for i := range removingList { - if err := c.client.Delete(context.TODO(), &removingList[i]); err != nil { + if err := c.client.Delete(ctx, &removingList[i]); err != nil { return err } } @@ -149,22 +162,48 @@ func (c *controller) add(ctx context.Context, queue *v1beta1.Queue, atTop bool) pQueue.Spec.NoOfOrder = queueList.TopQueueOrder() } - if err = c.client.Update(context.TODO(), pQueue); err != nil { + if err = c.client.Update(ctx, pQueue); err != nil { return err } } else { + isNewQueue := true + if isAlreadyInBundle { + queue, isNewQueue = c.generateBundleQueue(queue, bundleQueue) + // reset NoOfRetry/NextProcessAt if there is new component join the bundle + queue.Spec.NoOfRetry = 0 + queue.Spec.NextProcessAt = nil + } + // queue not exist if atTop { queue.Spec.NoOfOrder = queueList.TopQueueOrder() } else { - queue.Spec.NoOfOrder = queueList.LastQueueOrder() + if isAlreadyInBundle { + queue.Spec.NoOfOrder = bundleQueue.Spec.NoOfOrder + } else { + queue.Spec.NoOfOrder = queueList.LastQueueOrder() + } } - queue.Status.State = v1beta1.Waiting + queue.Status.State = s2hv1beta1.Waiting queue.Status.CreatedAt = &now queue.Status.UpdatedAt = &now - if err = c.client.Create(context.TODO(), queue); err != nil { + if isNewQueue { + if err = c.client.Create(ctx, queue); err != nil { + return err + } + + // delete old queue if creating a new bundle queue + if isAlreadyInBundle { + if err = c.client.Delete(ctx, bundleQueue); err != nil { + return err + } + } + return nil + } + + if err = c.client.Update(ctx, queue); err != nil { return err } } @@ -172,8 +211,8 @@ func (c *controller) add(ctx context.Context, queue *v1beta1.Queue, atTop bool) return nil } -func (c *controller) isMatchWithStableComponent(ctx context.Context, q *v1beta1.Queue) (isMatch bool, err error) { - stableComp := &v1beta1.StableComponent{} +func (c *controller) isMatchWithStableComponent(ctx context.Context, q *s2hv1beta1.Queue) (isMatch bool, err error) { + stableComp := &s2hv1beta1.StableComponent{} err = c.client.Get(ctx, types.NamespacedName{Namespace: c.namespace, Name: q.GetName()}, stableComp) if err != nil && k8serrors.IsNotFound(err) { return false, nil @@ -187,10 +226,41 @@ func (c *controller) isMatchWithStableComponent(ctx context.Context, q *v1beta1. return } +func (c *controller) generateBundleQueue(targetQ *s2hv1beta1.Queue, existBundleQ *s2hv1beta1.Queue) (*s2hv1beta1.Queue, bool) { + isNewBundle := false + newBundleQueue := existBundleQ + if existBundleQ.Name != existBundleQ.Spec.Bundle { // e.g. redis != db + // create new bundle queue + newBundleQueue = NewUpgradeQueue(existBundleQ.Spec.TeamName, existBundleQ.Namespace, existBundleQ.Spec.Bundle, + existBundleQ.Spec.Bundle, existBundleQ.Spec.Components) + isNewBundle = true + } + + // append components if bundle exists + for _, tcomp := range targetQ.Spec.Components { + isFound := false + for j, ecomp := range existBundleQ.Spec.Components { + if ecomp.Name == tcomp.Name { + isFound = true + newBundleQueue.Spec.Components[j].Repository = tcomp.Repository + newBundleQueue.Spec.Components[j].Version = tcomp.Version + break + } + } + if !isFound { + newBundleQueue.Spec.Components = append(newBundleQueue.Spec.Components, tcomp) + } + } + + newBundleQueue.Spec.Components.Sort() + + return newBundleQueue, isNewBundle +} + // removeSimilar removes similar queue (same `name` from queue) from QueueList -func (c *controller) removeSimilar(queue *v1beta1.Queue, list *v1beta1.QueueList) []v1beta1.Queue { - var items []v1beta1.Queue - var removing []v1beta1.Queue +func (c *controller) removeSimilar(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) []s2hv1beta1.Queue { + var items []s2hv1beta1.Queue + var removing []s2hv1beta1.Queue var hasSameQueue = false for _, q := range list.Items { @@ -208,8 +278,8 @@ func (c *controller) removeSimilar(queue *v1beta1.Queue, list *v1beta1.QueueList return removing } -func (c *controller) list(opts *client.ListOptions) (list *v1beta1.QueueList, err error) { - list = &v1beta1.QueueList{} +func (c *controller) list(opts *client.ListOptions) (list *s2hv1beta1.QueueList, err error) { + list = &s2hv1beta1.QueueList{} if opts == nil { opts = &client.ListOptions{Namespace: c.namespace} } @@ -219,7 +289,7 @@ func (c *controller) list(opts *client.ListOptions) (list *v1beta1.QueueList, er return list, nil } -func (c *controller) SetLastOrder(q *v1beta1.Queue) error { +func (c *controller) SetLastOrder(q *s2hv1beta1.Queue) error { queueList, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -232,7 +302,7 @@ func (c *controller) SetLastOrder(q *v1beta1.Queue) error { return c.client.Update(context.TODO(), q) } -func (c *controller) SetReverifyQueueAtFirst(q *v1beta1.Queue) error { +func (c *controller) SetReverifyQueueAtFirst(q *s2hv1beta1.Queue) error { list, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -240,17 +310,17 @@ func (c *controller) SetReverifyQueueAtFirst(q *v1beta1.Queue) error { } now := metav1.Now() - q.Status = v1beta1.QueueStatus{ + q.Status = s2hv1beta1.QueueStatus{ CreatedAt: &now, NoOfProcessed: q.Status.NoOfProcessed, - State: v1beta1.Waiting, + State: s2hv1beta1.Waiting, } - q.Spec.Type = v1beta1.QueueTypeReverify + q.Spec.Type = s2hv1beta1.QueueTypeReverify q.Spec.NoOfOrder = list.TopQueueOrder() return c.client.Update(context.TODO(), q) } -func (c *controller) SetRetryQueue(q *v1beta1.Queue, noOfRetry int, nextAt time.Time) error { +func (c *controller) SetRetryQueue(q *s2hv1beta1.Queue, noOfRetry int, nextAt time.Time) error { list, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -258,19 +328,19 @@ func (c *controller) SetRetryQueue(q *v1beta1.Queue, noOfRetry int, nextAt time. } now := metav1.Now() - q.Status = v1beta1.QueueStatus{ + q.Status = s2hv1beta1.QueueStatus{ CreatedAt: &now, NoOfProcessed: q.Status.NoOfProcessed, - State: v1beta1.Waiting, + State: s2hv1beta1.Waiting, } q.Spec.NextProcessAt = &metav1.Time{Time: nextAt} q.Spec.NoOfRetry = noOfRetry - q.Spec.Type = v1beta1.QueueTypeUpgrade + q.Spec.Type = s2hv1beta1.QueueTypeUpgrade q.Spec.NoOfOrder = list.LastQueueOrder() return c.client.Update(context.TODO(), q) } -func (c *controller) updateQueueList(ql *v1beta1.QueueList) error { +func (c *controller) updateQueueList(ql *s2hv1beta1.QueueList) error { for i := range ql.Items { if err := c.client.Update(context.TODO(), &ql.Items[i]); err != nil { logger.Error(err, "cannot update queue list", "queue", ql.Items[i].Name) @@ -282,7 +352,7 @@ func (c *controller) updateQueueList(ql *v1beta1.QueueList) error { } // resetQueueOrderWithCurrentQueue resets order of all queues to start with 1 respectively -func (c *controller) resetQueueOrderWithCurrentQueue(ql *v1beta1.QueueList, currentQueue *v1beta1.Queue) { +func (c *controller) resetQueueOrderWithCurrentQueue(ql *s2hv1beta1.QueueList, currentQueue *s2hv1beta1.Queue) { ql.Sort() count := 2 for i := range ql.Items { @@ -296,14 +366,14 @@ func (c *controller) resetQueueOrderWithCurrentQueue(ql *v1beta1.QueueList, curr } // EnsurePreActiveComponents ensures that components with were deployed with `pre-active` config and tested -func EnsurePreActiveComponents(c client.Client, teamName, namespace string) (q *v1beta1.Queue, err error) { - q = &v1beta1.Queue{ +func EnsurePreActiveComponents(c client.Client, teamName, namespace string) (q *s2hv1beta1.Queue, err error) { + q = &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ - Name: string(v1beta1.EnvPreActive), + Name: string(s2hv1beta1.EnvPreActive), Namespace: namespace, }, - Spec: v1beta1.QueueSpec{ - Type: v1beta1.QueueTypePreActive, + Spec: s2hv1beta1.QueueSpec{ + Type: s2hv1beta1.QueueTypePreActive, TeamName: teamName, }, } @@ -313,14 +383,14 @@ func EnsurePreActiveComponents(c client.Client, teamName, namespace string) (q * } // EnsurePromoteToActiveComponents ensures that components were deployed with `active` config -func EnsurePromoteToActiveComponents(c client.Client, teamName, namespace string) (q *v1beta1.Queue, err error) { - q = &v1beta1.Queue{ +func EnsurePromoteToActiveComponents(c client.Client, teamName, namespace string) (q *s2hv1beta1.Queue, err error) { + q = &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ - Name: string(v1beta1.EnvActive), + Name: string(s2hv1beta1.EnvActive), Namespace: namespace, }, - Spec: v1beta1.QueueSpec{ - Type: v1beta1.QueueTypePromoteToActive, + Spec: s2hv1beta1.QueueSpec{ + Type: s2hv1beta1.QueueTypePromoteToActive, TeamName: teamName, }, } @@ -329,14 +399,14 @@ func EnsurePromoteToActiveComponents(c client.Client, teamName, namespace string } // EnsureDemoteFromActiveComponents ensures that components were deployed without `active` config -func EnsureDemoteFromActiveComponents(c client.Client, teamName, namespace string) (q *v1beta1.Queue, err error) { - q = &v1beta1.Queue{ +func EnsureDemoteFromActiveComponents(c client.Client, teamName, namespace string) (q *s2hv1beta1.Queue, err error) { + q = &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ - Name: string(v1beta1.EnvDeActive), + Name: string(s2hv1beta1.EnvDeActive), Namespace: namespace, }, - Spec: v1beta1.QueueSpec{ - Type: v1beta1.QueueTypeDemoteFromActive, + Spec: s2hv1beta1.QueueSpec{ + Type: s2hv1beta1.QueueTypeDemoteFromActive, TeamName: teamName, }, } @@ -345,20 +415,20 @@ func EnsureDemoteFromActiveComponents(c client.Client, teamName, namespace strin } func DeletePreActiveQueue(c client.Client, ns string) error { - return deleteQueue(c, ns, string(v1beta1.EnvPreActive)) + return deleteQueue(c, ns, string(s2hv1beta1.EnvPreActive)) } func DeletePromoteToActiveQueue(c client.Client, ns string) error { - return deleteQueue(c, ns, string(v1beta1.EnvActive)) + return deleteQueue(c, ns, string(s2hv1beta1.EnvActive)) } func DeleteDemoteFromActiveQueue(c client.Client, ns string) error { - return deleteQueue(c, ns, string(v1beta1.EnvDeActive)) + return deleteQueue(c, ns, string(s2hv1beta1.EnvDeActive)) } // deleteQueue removes Queue in target namespace by name func deleteQueue(c client.Client, ns, name string) error { - q := &v1beta1.Queue{ + q := &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: ns, @@ -372,8 +442,8 @@ func deleteQueue(c client.Client, ns, name string) error { return errors.Wrap(err, "cannot delete queue") } -func ensureQueue(ctx context.Context, c client.Client, q *v1beta1.Queue) (err error) { - fetched := &v1beta1.Queue{} +func ensureQueue(ctx context.Context, c client.Client, q *s2hv1beta1.Queue) (err error) { + fetched := &s2hv1beta1.Queue{} err = c.Get(ctx, types.NamespacedName{Namespace: q.Namespace, Name: q.Name}, fetched) if err != nil { if k8serrors.IsNotFound(err) { diff --git a/internal/samsahai/internal_process.go b/internal/samsahai/internal_process.go index 9e6d211d..e224f71f 100644 --- a/internal/samsahai/internal_process.go +++ b/internal/samsahai/internal_process.go @@ -20,6 +20,7 @@ import ( const maxDesiredMappingPerComp = 10 +// TODO: pohfy, add bundle here type changedComponent struct { Name string Repository string @@ -37,6 +38,8 @@ type updateTeamDesiredComponent struct { ComponentName string ComponentSource string ComponentImage s2hv1beta1.ComponentImage + // TODO: pohfy, add bundle here + ComponentBundle string } func (c *controller) Start(stop <-chan struct{}) { @@ -142,18 +145,22 @@ func (c *controller) checkComponentChanged(component changedComponent) error { logger.Debug("component has been notified", "team", teamName, "component", comp.Name) + // TODO: pohfy, add component bundle here // add to queue for processing + bundleName := getBundleName(comp.Name, teamName, configCtrl) c.queue.Add(updateTeamDesiredComponent{ TeamName: teamName, ComponentName: comp.Name, ComponentSource: string(*comp.Source), ComponentImage: comp.Image, + ComponentBundle: bundleName, }) } } return nil } +// TODO: pohfy, this place call desired component // updateTeamDesiredComponent gets new version from checker and checks with DesiredComponent of team. // // updateInfo will always has valid checker (from checkComponentChanged) @@ -175,6 +182,7 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp compNs := team.Status.Namespace.Staging compName := updateInfo.ComponentName compRepository := updateInfo.ComponentImage.Repository + compBundle := updateInfo.ComponentBundle // TODO: do caching for better performance version, vErr := checker.GetVersion(compRepository, compName, checkPattern) @@ -225,6 +233,7 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp Version: version, Name: compName, Repository: compRepository, + Bundle: compBundle, }, Status: s2hv1beta1.DesiredComponentStatus{ CreatedAt: &now, @@ -244,14 +253,17 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp return err } + // TODO: pohfy, added bundle // DesiredComponent found, check the version - if desiredComp.Spec.Version == version && desiredComp.Spec.Repository == compRepository { + if desiredComp.Spec.Version == version && desiredComp.Spec.Repository == compRepository && + desiredComp.Spec.Bundle == compBundle { return nil } // Update when version or repository changed desiredComp.Spec.Version = version desiredComp.Spec.Repository = compRepository + desiredComp.Spec.Bundle = compBundle desiredComp.Status.UpdatedAt = &now if err = c.client.Update(ctx, desiredComp); err != nil { @@ -281,6 +293,19 @@ type desiredTime struct { desiredImageTime s2hv1beta1.DesiredImageTime } +func getBundleName(compName, teamName string, configCtrl internal.ConfigController) string { + bundles, _ := configCtrl.GetBundles(teamName) + for bundleName, comps := range bundles { + for _, comp := range comps { + if comp == compName { + return bundleName + } + } + } + + return "" +} + func deleteDesiredMappingOutOfRange(team *s2hv1beta1.Team, maxDesiredMapping int) { desiredMap := team.Status.DesiredComponentImageCreatedTime for compName, m := range desiredMap { diff --git a/internal/samsahai/rpc.go b/internal/samsahai/rpc.go index 4a6b83b8..ab19fa77 100644 --- a/internal/samsahai/rpc.go +++ b/internal/samsahai/rpc.go @@ -30,6 +30,7 @@ func (c *controller) authenticateRPC(ctx context.Context) error { return nil } +// TODO: pohfy, TeamWithCurrentComponents func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWithCurrentComponent) (*rpc.ImageList, error) { if err := c.authenticateRPC(ctx); err != nil { return nil, err diff --git a/internal/staging/controller.go b/internal/staging/controller.go index 438ca05e..4a121e53 100644 --- a/internal/staging/controller.go +++ b/internal/staging/controller.go @@ -159,6 +159,7 @@ func (c *controller) process() bool { } } + // TODO: pohfy, pick queues with same bundle queue := c.getCurrentQueue() switch queue.Spec.Type { diff --git a/internal/staging/image_missing.go b/internal/staging/image_missing.go index 549e9ffe..871550a2 100644 --- a/internal/staging/image_missing.go +++ b/internal/staging/image_missing.go @@ -13,6 +13,7 @@ import ( "github.com/agoda-com/samsahai/pkg/samsahai/rpc" ) +// TODO: pohfy, detects multiple queues func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { var err error headers := make(http.Header) @@ -24,6 +25,7 @@ func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { } var imgList *rpc.ImageList + // TODO: pohfy, TeamWithCurrentComponents should contain multiple components comp := &rpc.TeamWithCurrentComponent{ TeamName: c.teamName, CompName: queue.Name, @@ -37,6 +39,7 @@ func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { } if imgList != nil && imgList.Images != nil && len(imgList.Images) > 0 { + // TODO: pohfy, updateImageMissingWithQueueState receives multiple queues if err := c.updateImageMissingWithQueueState(queue, imgList); err != nil { return err } diff --git a/internal/staging/testrunner/teamcity/testrunner.go b/internal/staging/testrunner/teamcity/testrunner.go index 1ac452a5..64e1e5d4 100644 --- a/internal/staging/testrunner/teamcity/testrunner.go +++ b/internal/staging/testrunner/teamcity/testrunner.go @@ -176,7 +176,7 @@ func (t *testRunner) Trigger(testConfig *v1beta1.ConfigTestRunner, currentQueue } out := &TriggerResponse{} - if err := xml.Unmarshal([]byte(resp), out); err != nil { + if err := xml.Unmarshal(resp, out); err != nil { logger.Error(err, "cannot unmarshal xml response data") errCh <- err return From 463e514634ec17d1ab3393d730e5e28b52d0e568 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Tue, 2 Jun 2020 14:13:40 +0700 Subject: [PATCH 02/12] :construction: Deploy multiple components --- api/v1beta1/queue_types.go | 8 +- api/v1beta1/stablecomponent_types.go | 4 - ....samsahai.io_activepromotionhistories.yaml | 10 +- .../env.samsahai.io_activepromotions.yaml | 10 +- .../crds/env.samsahai.io_queuehistories.yaml | 10 +- config/crds/env.samsahai.io_queues.yaml | 4 - .../env.samsahai.io_stablecomponents.yaml | 5 +- config/crds/env.samsahai.io_teams.yaml | 12 +- internal/deploy.go | 3 - internal/queue/controller.go | 5 +- internal/staging/collect_result.go | 1 + internal/staging/deploy.go | 210 +++++++++--------- internal/staging/deploy/helm3/engine.go | 12 - internal/staging/deploy/mock/engine.go | 5 - 14 files changed, 120 insertions(+), 179 deletions(-) diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 1f2009c7..5323967c 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -213,9 +213,6 @@ type QueueStatus struct { // NoOfProcessed represents how many time that this queue had been processed NoOfProcessed int `json:"noOfProcessed,omitempty"` - // ReleaseName defines name of helmrelease - ReleaseName string `json:"releaseName"` - // Conditions contains observations of the resource's state e.g., // Queue deployed, being tested // +optional @@ -291,7 +288,6 @@ type Queue struct { Status QueueStatus `json:"status,omitempty"` } -// TODO: pohfy, updated func (q *Queue) IsSame(d *Queue) bool { if q.Spec.Name != d.Spec.Name { return false @@ -309,9 +305,7 @@ func (q *Queue) IsSame(d *Queue) bool { return false } } - //return q.Spec.Name == d.Spec.Name && - // q.Spec.Repository == d.Spec.Repository && - // q.Spec.Version == d.Spec.Version + return true } diff --git a/api/v1beta1/stablecomponent_types.go b/api/v1beta1/stablecomponent_types.go index a9e45239..dc1ad25c 100644 --- a/api/v1beta1/stablecomponent_types.go +++ b/api/v1beta1/stablecomponent_types.go @@ -20,7 +20,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// TODO: pohfy, updated // StableComponentSpec defines the desired state of StableComponent type StableComponentSpec struct { // Name represents Component name @@ -32,9 +31,6 @@ type StableComponentSpec struct { // Version represents Docker image tag version Version string `json:"version"` - // +optional - Bundle string `json:"bundle,omitempty"` - // UpdatedBy represents a person who updated the StableComponent // +optional UpdatedBy string `json:"updatedBy,omitempty"` diff --git a/config/crds/env.samsahai.io_activepromotionhistories.yaml b/config/crds/env.samsahai.io_activepromotionhistories.yaml index b3bc5f70..1d9d8b40 100644 --- a/config/crds/env.samsahai.io_activepromotionhistories.yaml +++ b/config/crds/env.samsahai.io_activepromotionhistories.yaml @@ -85,11 +85,9 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec - defines the desired state of StableComponent' + description: StableComponentSpec defines the desired state + of StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string @@ -271,9 +269,6 @@ spec: description: QueueHistoryName defines name of history of this queue type: string - releaseName: - description: ReleaseName defines name of helmrelease - type: string startDeployTime: description: StartDeployTime represents the time when this queue start deploying @@ -308,7 +303,6 @@ spec: required: - kubeZipLog - queueHistoryName - - releaseName - state type: object previousActiveNamespace: diff --git a/config/crds/env.samsahai.io_activepromotions.yaml b/config/crds/env.samsahai.io_activepromotions.yaml index 0705caac..07d9c008 100644 --- a/config/crds/env.samsahai.io_activepromotions.yaml +++ b/config/crds/env.samsahai.io_activepromotions.yaml @@ -62,11 +62,9 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec defines - the desired state of StableComponent' + description: StableComponentSpec defines the desired state of + StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string @@ -242,9 +240,6 @@ spec: queueHistoryName: description: QueueHistoryName defines name of history of this queue type: string - releaseName: - description: ReleaseName defines name of helmrelease - type: string startDeployTime: description: StartDeployTime represents the time when this queue start deploying @@ -278,7 +273,6 @@ spec: required: - kubeZipLog - queueHistoryName - - releaseName - state type: object previousActiveNamespace: diff --git a/config/crds/env.samsahai.io_queuehistories.yaml b/config/crds/env.samsahai.io_queuehistories.yaml index d810c469..0c05c4db 100644 --- a/config/crds/env.samsahai.io_queuehistories.yaml +++ b/config/crds/env.samsahai.io_queuehistories.yaml @@ -190,9 +190,6 @@ spec: description: QueueHistoryName defines name of history of this queue type: string - releaseName: - description: ReleaseName defines name of helmrelease - type: string startDeployTime: description: StartDeployTime represents the time when this queue start deploying @@ -227,7 +224,6 @@ spec: required: - kubeZipLog - queueHistoryName - - releaseName - state type: object type: object @@ -251,11 +247,9 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec defines - the desired state of StableComponent' + description: StableComponentSpec defines the desired state of + StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_queues.yaml b/config/crds/env.samsahai.io_queues.yaml index 058a0c76..7b5050f9 100644 --- a/config/crds/env.samsahai.io_queues.yaml +++ b/config/crds/env.samsahai.io_queues.yaml @@ -156,9 +156,6 @@ spec: queueHistoryName: description: QueueHistoryName defines name of history of this queue type: string - releaseName: - description: ReleaseName defines name of helmrelease - type: string startDeployTime: description: StartDeployTime represents the time when this queue start deploying @@ -192,7 +189,6 @@ spec: required: - kubeZipLog - queueHistoryName - - releaseName - state type: object type: object diff --git a/config/crds/env.samsahai.io_stablecomponents.yaml b/config/crds/env.samsahai.io_stablecomponents.yaml index 7d5cad39..b8c6c806 100644 --- a/config/crds/env.samsahai.io_stablecomponents.yaml +++ b/config/crds/env.samsahai.io_stablecomponents.yaml @@ -32,11 +32,8 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec defines the desired - state of StableComponent' + description: StableComponentSpec defines the desired state of StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string diff --git a/config/crds/env.samsahai.io_teams.yaml b/config/crds/env.samsahai.io_teams.yaml index 375d370e..c797e5a2 100644 --- a/config/crds/env.samsahai.io_teams.yaml +++ b/config/crds/env.samsahai.io_teams.yaml @@ -158,11 +158,9 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec defines - the desired state of StableComponent' + description: StableComponentSpec defines the desired state of + StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string @@ -253,11 +251,9 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, updated StableComponentSpec defines - the desired state of StableComponent' + description: StableComponentSpec defines the desired state of + StableComponent properties: - bundle: - type: string name: description: Name represents Component name type: string diff --git a/internal/deploy.go b/internal/deploy.go index 7c36b92f..7b6e287d 100644 --- a/internal/deploy.go +++ b/internal/deploy.go @@ -20,9 +20,6 @@ type DeployEngine interface { // ForceDelete deletes environment when timeout ForceDelete(refName string) error - // IsReady checks the environment is ready to use or not - IsReady(queue *v1beta1.Queue) (bool, error) - // GetLabelSelector returns map of label for select the components that created by the engine GetLabelSelectors(refName string) map[string]string diff --git a/internal/queue/controller.go b/internal/queue/controller.go index a059eafa..b06360c5 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -41,10 +41,6 @@ func NewUpgradeQueue(teamName, namespace, name, bundle string, comps []*s2hv1bet TeamName: teamName, Bundle: bundle, Components: comps, - // TODO: pohfy, start remove here - //Repository: repository, - //Version: version, - // TODO: pohfy, end remove here Type: s2hv1beta1.QueueTypeUpgrade, }, Status: s2hv1beta1.QueueStatus{}, @@ -220,6 +216,7 @@ func (c *controller) isMatchWithStableComponent(ctx context.Context, q *s2hv1bet return } + // TODO: pohfy, update here isMatch = stableComp.Spec.Repository == q.Spec.Repository && stableComp.Spec.Version == q.Spec.Version diff --git a/internal/staging/collect_result.go b/internal/staging/collect_result.go index 082dab55..de7a0c0a 100644 --- a/internal/staging/collect_result.go +++ b/internal/staging/collect_result.go @@ -187,6 +187,7 @@ func (c *controller) deleteQueueHistoryOutOfRange(ctx context.Context, namespace return nil } +// // setStableComponent creates or updates StableComponent to match with Queue func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { const updatedBy = "samsahai" diff --git a/internal/staging/deploy.go b/internal/staging/deploy.go index 226d3bbe..146d4d86 100644 --- a/internal/staging/deploy.go +++ b/internal/staging/deploy.go @@ -19,6 +19,7 @@ import ( "github.com/agoda-com/samsahai/internal/util/valuesutil" ) +// TODO: pohfy, update here // deployEnvironment deploy components into namespace func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { deployTimeout := metav1.Duration{Duration: 1800 * time.Second} @@ -34,54 +35,49 @@ func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { return err } - var comp *s2hv1beta1.Component - var parentComp *s2hv1beta1.Component + queueComps := make(map[string]*s2hv1beta1.Component) // map[component name]component + queueParentComps := make(map[string]*s2hv1beta1.Component) // map[parent component name]parent component switch queue.Spec.Type { case s2hv1beta1.QueueTypePreActive, s2hv1beta1.QueueTypePromoteToActive, s2hv1beta1.QueueTypeDemoteFromActive: - queue.Status.ReleaseName = string(queue.Spec.Type) - if err := c.updateQueue(queue); err != nil { return err } default: // Upgrade, Reverify - if err := c.validateQueue(queue); err != nil { - return err + if isValid, err := c.validateQueue(queue); err != nil || !isValid { + if err != nil { + return err + } + return nil } - comps, err := c.getConfigController().GetComponents(c.teamName) + configCtrl := c.getConfigController() + comps, err := configCtrl.GetComponents(c.teamName) if err != nil { return err } - var ok bool - comp, ok = comps[queue.Spec.Name] - if !ok { - // delete queue if component does not exist in config - if err := c.client.Delete(context.TODO(), queue); err != nil { - logger.Error(err, "deleting queue error") - return err + for _, qcomp := range queue.Spec.Components { + comp, ok := comps[qcomp.Name] + if !ok { + continue } - c.clearCurrentQueue() - return nil - } - parentComp = comp + queueComps[qcomp.Name] = comp + queueParentComps[qcomp.Name] = comp - if comp.Parent != "" { - parentComp = comps[comp.Parent] - } - - // checking if release name was generated - if err := c.createReleaseName(queue, parentComp); err != nil { - return err + if comp.Parent != "" { + delete(queueParentComps, qcomp.Name) + queueParentComps[comp.Parent] = comps[comp.Parent] + } } } // Deploy if !queue.Status.IsConditionTrue(s2hv1beta1.QueueDeployStarted) { - err := c.deployComponents(deployEngine, queue, comp, parentComp) + // TODO: pohfy, fix here + err := c.deployComponents(deployEngine, queue, queueComps, queueParentComps) if err != nil { return err } @@ -95,16 +91,6 @@ func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { } } - if c.isUpgradeRelatedQueue(queue) { - isReady, err := deployEngine.IsReady(queue) - if err != nil { - return err - } else if !isReady { - time.Sleep(2 * time.Second) - return nil - } - } - // checking environment is ready // change state if ready isReady, err := c.waitForComponentsReady(deployEngine) @@ -143,7 +129,7 @@ func (c *controller) checkDeployTimeout(queue *s2hv1beta1.Queue, deployTimeout m return err } - logger.Error(s2herrors.ErrDeployTimeout, fmt.Sprintf("release: %s deploy timeout", queue.Status.ReleaseName)) + logger.Error(s2herrors.ErrDeployTimeout, fmt.Sprintf("queue: %s deploy timeout", queue.Name)) return s2herrors.ErrDeployTimeout } @@ -151,36 +137,46 @@ func (c *controller) checkDeployTimeout(queue *s2hv1beta1.Queue, deployTimeout m return nil } -// -func (c *controller) createReleaseName(queue *s2hv1beta1.Queue, parentCom *s2hv1beta1.Component) error { - if queue.Status.ReleaseName == "" { - queue.Status.ReleaseName = c.genReleaseName(parentCom) - if err := c.updateQueue(queue); err != nil { - return err - } - } - return nil -} - // validateQueue checks if Queue exist in Configuration. -func (c *controller) validateQueue(queue *s2hv1beta1.Queue) error { - comps, err := c.getConfigController().GetComponents(c.teamName) +func (c *controller) validateQueue(queue *s2hv1beta1.Queue) (bool, error) { + configCtrl := c.getConfigController() + comps, err := configCtrl.GetComponents(c.teamName) if err != nil { - return err + return false, err } - var isCompExist bool + isBundleQueue := queue.Spec.Bundle != "" && queue.Spec.Name == queue.Spec.Bundle + bundles, err := configCtrl.GetBundles(c.teamName) + if err != nil { + return false, err + } - if _, isCompExist = comps[queue.Spec.Name]; !isCompExist { + isNotExist := false + if isBundleQueue { + // delete queue if no bundle exist in config + if _, ok := bundles[queue.Spec.Name]; !ok { + isNotExist = true + } + } else { + if len(queue.Spec.Components) == 0 { + isNotExist = true + } else { + // delete queue if component does not exist in config + if _, ok := comps[queue.Spec.Components[0].Name]; !ok { + isNotExist = true + } + } + } - // delete queue - if err := c.deleteQueue(queue); err != nil { - return err + if isNotExist { + if err := c.client.Delete(context.TODO(), queue); err != nil { + logger.Error(err, "deleting queue error") + return false, err } - return nil + c.clearCurrentQueue() } - return nil + return true, nil } func (c *controller) getStableComponentsMap() (stableMap map[string]s2hv1beta1.StableComponent, err error) { @@ -193,13 +189,19 @@ func (c *controller) getStableComponentsMap() (stableMap map[string]s2hv1beta1.S return } -func genCompValueFromQueue(queue *s2hv1beta1.Queue) map[string]interface{} { - return map[string]interface{}{ - "image": map[string]interface{}{ - "repository": queue.Spec.Repository, - "tag": queue.Spec.Version, - }, +func genCompValueFromQueue(compName string, qcomps []*s2hv1beta1.QueueComponent) map[string]interface{} { + for _, qcomp := range qcomps { + if qcomp.Name == compName { + return map[string]interface{}{ + "image": map[string]interface{}{ + "repository": qcomp.Repository, + "tag": qcomp.Version, + }, + } + } } + + return map[string]interface{}{} } // applyEnvBaseConfig applies input values with specific env. configuration based on Queue.Spec.Type @@ -242,8 +244,8 @@ func applyEnvBaseConfig( func (c *controller) deployComponents( deployEngine internal.DeployEngine, queue *s2hv1beta1.Queue, - comp *s2hv1beta1.Component, - parentComp *s2hv1beta1.Component, + queueComps map[string]*s2hv1beta1.Component, + queueParentComps map[string]*s2hv1beta1.Component, ) error { stableMap, err := c.getStableComponentsMap() @@ -251,7 +253,7 @@ func (c *controller) deployComponents( return err } - err = c.deployComponentsExceptQueue(deployEngine, queue, parentComp, stableMap) + err = c.deployComponentsExceptQueue(deployEngine, queue, queueParentComps, stableMap) if err != nil { return err } @@ -261,7 +263,7 @@ func (c *controller) deployComponents( return nil } - err = c.deployQueueComponent(deployEngine, queue, comp, parentComp, stableMap) + err = c.deployQueueComponent(deployEngine, queue, queueComps, queueParentComps, stableMap) if err != nil { return err } @@ -277,7 +279,7 @@ func (c *controller) isUpgradeRelatedQueue(q *s2hv1beta1.Queue) bool { func (c *controller) deployComponentsExceptQueue( deployEngine internal.DeployEngine, queue *s2hv1beta1.Queue, - queueParentComp *s2hv1beta1.Component, + queueParentComps map[string]*s2hv1beta1.Component, stableMap map[string]s2hv1beta1.StableComponent, ) error { parentComps, err := c.getConfigController().GetParentComponents(c.teamName) @@ -285,19 +287,14 @@ func (c *controller) deployComponentsExceptQueue( return err } - queueParentCompName := "" - if queueParentComp != nil { - queueParentCompName = queueParentComp.Name - } - cfg, err := c.getConfiguration() if err != nil { return err } for name, comp := range parentComps { - // skip current Queue - if queueParentCompName == name { + // skip current queue + if _, ok := queueParentComps[name]; ok { continue } @@ -324,42 +321,49 @@ func (c *controller) deployComponentsExceptQueue( func (c *controller) deployQueueComponent( deployEngine internal.DeployEngine, queue *s2hv1beta1.Queue, - comp *s2hv1beta1.Component, - parentComp *s2hv1beta1.Component, + queueComps map[string]*s2hv1beta1.Component, + queueParentComps map[string]*s2hv1beta1.Component, stableMap map[string]s2hv1beta1.StableComponent, ) error { + cfg, err := c.getConfiguration() if err != nil { return err } - baseValues, err := configctrl.GetEnvComponentValues(cfg, parentComp.Name, s2hv1beta1.EnvBase) - if err != nil { - return err - } + // deploy current queue + for name, parentComp := range queueParentComps { + baseValues, err := configctrl.GetEnvComponentValues(cfg, name, s2hv1beta1.EnvBase) + if err != nil { + return err + } - values := valuesutil.GenStableComponentValues( - parentComp, - stableMap, - baseValues, - ) - if queue.Spec.Type == s2hv1beta1.QueueTypeUpgrade { - // merge stable only matched component or dependencies - v := genCompValueFromQueue(queue) - if comp.Name == parentComp.Name { - // queue is parent - values = valuesutil.MergeValues(values, v) - } else if comp.Parent != "" && comp.Parent == parentComp.Name { - // queue is dependency of parent - values = valuesutil.MergeValues(values, map[string]interface{}{ - comp.Name: v, - }) + values := valuesutil.GenStableComponentValues( + parentComp, + stableMap, + baseValues, + ) + + if queue.Spec.Type == s2hv1beta1.QueueTypeUpgrade { + // merge stable only matched component or dependencies + for _, comp := range queueComps { + v := genCompValueFromQueue(comp.Name, queue.Spec.Components) + if comp.Name == parentComp.Name { + // queue is parent + values = valuesutil.MergeValues(values, v) + } else if comp.Parent != "" && comp.Parent == parentComp.Name { + // queue is dependency of parent + values = valuesutil.MergeValues(values, map[string]interface{}{ + comp.Name: v, + }) + } + } } - } - values = applyEnvBaseConfig(cfg, values, queue.Spec.Type, parentComp) - if err := deployEngine.Create(c.genReleaseName(parentComp), comp, parentComp, values); err != nil { - return err + values = applyEnvBaseConfig(cfg, values, queue.Spec.Type, parentComp) + if err := deployEngine.Create(c.genReleaseName(parentComp), parentComp, parentComp, values); err != nil { + return err + } } return nil @@ -395,8 +399,6 @@ func (c *controller) waitForReady(selectors map[string]string) (bool, error) { LabelSelector: labels.SelectorFromSet(selectors), } - //listOpt := metav1.ListOptions{LabelSelector: labels.SelectorFromSet(selectors).String()} - // check pods if isReady, err := c.isPodsReady(listOpt); err != nil || !isReady { return false, err diff --git a/internal/staging/deploy/helm3/engine.go b/internal/staging/deploy/helm3/engine.go index b7071a11..83bf9a28 100644 --- a/internal/staging/deploy/helm3/engine.go +++ b/internal/staging/deploy/helm3/engine.go @@ -198,18 +198,6 @@ func (e *engine) helmUninstall(refName string, disableHooks bool) error { return nil } -func (e *engine) IsReady(queue *v1beta1.Queue) (bool, error) { - refName := queue.Status.ReleaseName - - client := action.NewStatus(e.actionSettings) - rel, err := client.Run(refName) - if err != nil { - return false, errors.Wrap(err, "cannot get status of helm release") - } - - return rel.Info.Status == release.StatusDeployed, nil -} - func (e *engine) helmInit() error { if atomic.LoadUint32(&e.initDone) == 1 { return nil diff --git a/internal/staging/deploy/mock/engine.go b/internal/staging/deploy/mock/engine.go index eb8dd992..206d6a55 100644 --- a/internal/staging/deploy/mock/engine.go +++ b/internal/staging/deploy/mock/engine.go @@ -66,11 +66,6 @@ func (e *engine) GetValues() (map[string][]byte, error) { return nil, nil } -func (e *engine) IsReady(queue *v1beta1.Queue) (bool, error) { - logger.Debug(fmt.Sprintf("env with resource key '%s' is ready", queue.Status.ReleaseName)) - return true, nil -} - func (e *engine) GetName() string { return EngineName } From 9e73afe6c2bfce041ac18cb53593399dcb332e0a Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Tue, 2 Jun 2020 18:42:44 +0700 Subject: [PATCH 03/12] :bento: Update reporter to support multiple components --- go.mod | 3 +- go.sum | 24 + internal/queue/controller.go | 29 +- internal/reporter/msteams/reporter.go | 33 +- internal/reporter/slack/reporter.go | 35 +- internal/staging/collect_result.go | 113 +-- internal/staging/deploy.go | 12 +- pkg/samsahai/rpc/service.pb.go | 977 ++++++++++++++++++-------- pkg/samsahai/rpc/service.proto | 7 +- pkg/samsahai/rpc/service.twirp.go | 99 +-- pkg/staging/rpc/service.pb.go | 157 +++-- pkg/staging/rpc/service.twirp.go | 10 +- 12 files changed, 1007 insertions(+), 492 deletions(-) diff --git a/go.mod b/go.mod index ff9041b6..bf577f21 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-logr/logr v0.1.0 github.com/go-logr/zapr v0.1.1 // indirect github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7 // indirect - github.com/golang/protobuf v1.3.2 + github.com/golang/protobuf v1.4.1 github.com/google/go-cmp v0.4.0 github.com/google/uuid v1.1.1 github.com/json-iterator/go v1.1.9 // indirect @@ -35,6 +35,7 @@ require ( golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect golang.org/x/sys v0.0.0-20200107162124-548cf772de50 // indirect + google.golang.org/protobuf v1.24.0 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/yaml.v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index 4f18f53b..b1b89538 100644 --- a/go.sum +++ b/go.sum @@ -77,6 +77,7 @@ github.com/bugsnag/bugsnag-go v1.5.0 h1:tP8hiPv1pGGW3LA6LKy5lW6WG+y9J2xWUdPd3WC4 github.com/bugsnag/bugsnag-go v1.5.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA= github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -143,6 +144,8 @@ github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.11.1+incompatible h1:CjKsv3uWcCMvySPQYKxO8XX3f9zD4FeZRsW4G0B4ffE= github.com/emicklei/go-restful v2.11.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -272,6 +275,13 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkYFkPcDKwRXegd+iM6E7matEszMG5HhwytU8= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= @@ -739,8 +749,11 @@ google.golang.org/genproto v0.0.0-20190128161407-8ac453e89fca/go.mod h1:L3J43x8/ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 h1:UXl+Zk3jqqcbEVV7ace5lrt4YdA4tXiz3f/KbmD29Vo= google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -748,6 +761,17 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= diff --git a/internal/queue/controller.go b/internal/queue/controller.go index b06360c5..091ba8e5 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -41,7 +41,7 @@ func NewUpgradeQueue(teamName, namespace, name, bundle string, comps []*s2hv1bet TeamName: teamName, Bundle: bundle, Components: comps, - Type: s2hv1beta1.QueueTypeUpgrade, + Type: s2hv1beta1.QueueTypeUpgrade, }, Status: s2hv1beta1.QueueStatus{}, } @@ -125,18 +125,17 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo isAlreadyInQueue := false isAlreadyInBundle := false for i, q := range queueList.Items { - if q.IsInExistBundle(queue) { - isAlreadyInBundle = true - bundleQueue = &queueList.Items[i] - break - } - - // TODO: pohfy, need to be updated if q.IsSame(queue) { isAlreadyInQueue = true pQueue = &queueList.Items[i] break } + + if q.IsInExistBundle(queue) { + isAlreadyInBundle = true + bundleQueue = &queueList.Items[i] + break + } } // remove duplicate component @@ -207,18 +206,24 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo return nil } +// queue always contains 1 component func (c *controller) isMatchWithStableComponent(ctx context.Context, q *s2hv1beta1.Queue) (isMatch bool, err error) { + if len(q.Spec.Components) == 0 { + isMatch = true + return + } + + qcomp := q.Spec.Components[0] stableComp := &s2hv1beta1.StableComponent{} - err = c.client.Get(ctx, types.NamespacedName{Namespace: c.namespace, Name: q.GetName()}, stableComp) + err = c.client.Get(ctx, types.NamespacedName{Namespace: c.namespace, Name: qcomp.Name}, stableComp) if err != nil && k8serrors.IsNotFound(err) { return false, nil } else if err != nil { return } - // TODO: pohfy, update here - isMatch = stableComp.Spec.Repository == q.Spec.Repository && - stableComp.Spec.Version == q.Spec.Version + isMatch = stableComp.Spec.Repository == qcomp.Repository && + stableComp.Spec.Version == qcomp.Version return } diff --git a/internal/reporter/msteams/reporter.go b/internal/reporter/msteams/reporter.go index 24fac679..bb3ccdd7 100644 --- a/internal/reporter/msteams/reporter.go +++ b/internal/reporter/msteams/reporter.go @@ -202,20 +202,23 @@ func (r *reporter) makeComponentUpgradeReport(comp *internal.ComponentUpgradeRep message := ` Component Upgrade: Success {{ else }}` + styleDanger + `> Failure{{ end }} {{- if eq .Status 0 }} -
  • Issue type: {{ .IssueTypeStr }}
  • +Issue type: {{ .IssueTypeStr }} {{- end }} -
  • Run:{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }}
  • -
  • Component: {{ .Name }}
  • -
  • Version: {{ .Image.Tag }}
  • -
  • Repository: {{ .Image.Repository }}
  • -
  • Owner: {{ .TeamName }}
  • -
  • Namespace: {{ .Namespace }}
  • +
    Run:{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }} +
    Components +{{- range .Components }} +
  • - Name: {{ .Name }}
  • +
  •   Version: {{ .Image.Tag }}
  • +
  •   Repository: {{ .Image.Repository }}
  • +{{- end }} +
    Owner: {{ .TeamName }} +
    Namespace: {{ .Namespace }} {{- if eq .Status 0 }} {{- if .TestRunner.Teamcity.BuildURL }} -
  • Teamcity URL: Click here
  • +
    Teamcity URL: Click here {{- end }} -
  • Deployment Logs: Download here
  • -
  • Deployment History: Click here
  • +
    Deployment Logs: Download here +
    Deployment History: Click here {{- end}} ` return strings.TrimSpace(template.TextRender("MSTeamsComponentUpgradeFailure", message, comp)) @@ -231,15 +234,15 @@ func (r *reporter) makeActivePromotionStatusReport(comp *internal.ActivePromotio {{- end }} {{- end }} {{- end }} -
  • Current Active Namespace: {{ .CurrentActiveNamespace }}
  • -
  • Owner: {{ .TeamName }}
  • +
    Current Active Namespace: {{ .CurrentActiveNamespace }} +
    Owner: {{ .TeamName }} {{- if and .PreActiveQueue.TestRunner (and .PreActiveQueue.TestRunner.Teamcity .PreActiveQueue.TestRunner.Teamcity.BuildURL) }} -
  • Teamcity URL: Click here
  • +
    Teamcity URL: Click here {{- end }} {{- if eq .Result "Failure" }} -
  • Deployment Logs: Download here
  • +
    Deployment Logs: Download here {{- end }} -
  • Active Promotion History: Click here
  • +
    Active Promotion History: Click here ` return strings.TrimSpace(template.TextRender("MSTeamsActivePromotionStatus", message, comp)) diff --git a/internal/reporter/slack/reporter.go b/internal/reporter/slack/reporter.go index 20656478..e26bb0eb 100644 --- a/internal/reporter/slack/reporter.go +++ b/internal/reporter/slack/reporter.go @@ -198,20 +198,23 @@ func (r *reporter) makeComponentUpgradeReport(comp *internal.ComponentUpgradeRep message := ` *Component Upgrade:*{{ if eq .Status 1 }} Success {{ else }} Failure {{ end }} {{- if eq .Status 0 }} ->*Issue type:* {{ .IssueTypeStr }} +*Issue type:* {{ .IssueTypeStr }} {{- end }} ->*Run:*{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }} ->*Component:* {{ .Name }} ->*Version:* {{ .Image.Tag }} ->*Repository:* {{ .Image.Repository }} ->*Owner:* {{ .TeamName }} ->*Namespace:* {{ .Namespace }} +*Run:*{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }} +*Components* +{{- range .Components }} +>- *Name:* {{ .Name }} +> *Version:* {{ .Image.Tag }} +> *Repository:* {{ .Image.Repository }} +{{- end }} +*Owner:* {{ .TeamName }} +*Namespace:* {{ .Namespace }} {{- if eq .Status 0 }} {{- if .TestRunner.Teamcity.BuildURL }} ->*Teamcity URL:* <{{ .TestRunner.Teamcity.BuildURL }}|Click here> +*Teamcity URL:* <{{ .TestRunner.Teamcity.BuildURL }}|Click here> {{- end }} ->*Deployment Logs:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/queue/histories/{{ .QueueHistoryName }}/log|Download here> ->*Deployment History:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/queue/histories/{{ .QueueHistoryName }}|Click here> +*Deployment Logs:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/queue/histories/{{ .QueueHistoryName }}/log|Download here> +*Deployment History:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/queue/histories/{{ .QueueHistoryName }}|Click here> {{- end}} ` return strings.TrimSpace(template.TextRender("SlackComponentUpgradeFailure", message, comp)) @@ -223,19 +226,19 @@ func (r *reporter) makeActivePromotionStatusReport(comp *internal.ActivePromotio {{- if ne .Result "Success" }} {{- range .Conditions }} {{- if eq .Type "` + string(s2hv1beta1.ActivePromotionCondActivePromoted) + `" }} ->*Reason:* {{ .Message }} +*Reason:* {{ .Message }} {{- end }} {{- end }} {{- end }} ->*Current Active Namespace:* {{ .CurrentActiveNamespace }} ->*Owner:* {{ .TeamName }} +*Current Active Namespace:* {{ .CurrentActiveNamespace }} +*Owner:* {{ .TeamName }} {{- if and .PreActiveQueue.TestRunner (and .PreActiveQueue.TestRunner.Teamcity .PreActiveQueue.TestRunner.Teamcity.BuildURL) }} ->*Teamcity URL:* <{{ .PreActiveQueue.TestRunner.Teamcity.BuildURL }}|Click here> +*Teamcity URL:* <{{ .PreActiveQueue.TestRunner.Teamcity.BuildURL }}|Click here> {{- end }} {{- if eq .Result "Failure" }} ->*Deployment Logs:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/activepromotions/histories/{{ .ActivePromotionHistoryName }}/log|Download here> +*Deployment Logs:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/activepromotions/histories/{{ .ActivePromotionHistoryName }}/log|Download here> {{- end }} ->*Active Promotion History:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/activepromotions/histories/{{ .ActivePromotionHistoryName }}|Click here> +*Active Promotion History:* <{{ .SamsahaiExternalURL }}/teams/{{ .TeamName }}/activepromotions/histories/{{ .ActivePromotionHistoryName }}|Click here> ` return strings.TrimSpace(template.TextRender("SlackActivePromotionStatus", message, comp)) diff --git a/internal/staging/collect_result.go b/internal/staging/collect_result.go index de7a0c0a..695a81d0 100644 --- a/internal/staging/collect_result.go +++ b/internal/staging/collect_result.go @@ -187,64 +187,65 @@ func (c *controller) deleteQueueHistoryOutOfRange(ctx context.Context, namespace return nil } -// // setStableComponent creates or updates StableComponent to match with Queue func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { const updatedBy = "samsahai" - stableComp := &s2hv1beta1.StableComponent{} - err = c.client.Get( - context.TODO(), - types.NamespacedName{Namespace: queue.GetNamespace(), Name: queue.GetName()}, - stableComp) - if err != nil && k8serrors.IsNotFound(err) { - now := metav1.Now() - stableLabels := internal.GetDefaultLabels(c.teamName) - stableLabels["app"] = queue.Name - stableComp := &s2hv1beta1.StableComponent{ - ObjectMeta: metav1.ObjectMeta{ - Name: queue.Name, - Namespace: queue.Namespace, - Labels: stableLabels, - }, - Spec: s2hv1beta1.StableComponentSpec{ - Name: queue.Spec.Name, - Version: queue.Spec.Version, - Repository: queue.Spec.Repository, - UpdatedBy: updatedBy, - }, - Status: s2hv1beta1.StableComponentStatus{ - CreatedAt: &now, - UpdatedAt: &now, - }, - } - err = c.client.Create(context.TODO(), stableComp) - if err != nil { - logger.Error(err, fmt.Sprintf("cannot create StableComponent: %s/%s", queue.GetNamespace(), queue.GetName())) - return - } + for _, qcomp := range queue.Spec.Components { + stableComp := &s2hv1beta1.StableComponent{} + err = c.client.Get( + context.TODO(), + types.NamespacedName{Namespace: queue.GetNamespace(), Name: qcomp.Name}, + stableComp) + if err != nil && k8serrors.IsNotFound(err) { + now := metav1.Now() + stableLabels := internal.GetDefaultLabels(c.teamName) + stableLabels["app"] = qcomp.Name + stableComp := &s2hv1beta1.StableComponent{ + ObjectMeta: metav1.ObjectMeta{ + Name: qcomp.Name, + Namespace: queue.Namespace, + Labels: stableLabels, + }, + Spec: s2hv1beta1.StableComponentSpec{ + Name: qcomp.Name, + Version: qcomp.Version, + Repository: qcomp.Repository, + UpdatedBy: updatedBy, + }, + Status: s2hv1beta1.StableComponentStatus{ + CreatedAt: &now, + UpdatedAt: &now, + }, + } + err = c.client.Create(context.TODO(), stableComp) + if err != nil { + logger.Error(err, fmt.Sprintf("cannot create StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + return + } - return nil + return nil - } else if err != nil { - logger.Error(err, fmt.Sprintf("cannot get StableComponent: %s/%s", queue.GetNamespace(), queue.GetName())) - return err - } + } else if err != nil { + logger.Error(err, fmt.Sprintf("cannot get StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + return err + } - if stableComp.Spec.Version == queue.Spec.Version && - stableComp.Spec.Repository == queue.Spec.Repository { - // no change - return nil - } + if stableComp.Spec.Version == qcomp.Version && + stableComp.Spec.Repository == qcomp.Repository { + // no change + return nil + } - stableComp.Spec.Repository = queue.Spec.Repository - stableComp.Spec.Version = queue.Spec.Version - stableComp.Spec.UpdatedBy = updatedBy + stableComp.Spec.Repository = qcomp.Repository + stableComp.Spec.Version = qcomp.Version + stableComp.Spec.UpdatedBy = updatedBy - err = c.client.Update(context.TODO(), stableComp) - if err != nil { - logger.Error(err, fmt.Sprintf("cannot update StableComponent: %s/%s", queue.GetNamespace(), queue.GetName())) - return + err = c.client.Update(context.TODO(), stableComp) + if err != nil { + logger.Error(err, fmt.Sprintf("cannot update StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + return + } } return nil @@ -392,11 +393,23 @@ func (c *controller) sendComponentUpgradeReport(status rpc.ComponentUpgrade_Upgr outImgList = append(outImgList, &rpc.Image{Repository: img.Repository, Tag: img.Tag}) } + rpcComps := make([]*rpc.Component, 0) + for _, qcomp := range queue.Spec.Components { + rpcComps = append(rpcComps, &rpc.Component{ + Name: qcomp.Name, + Image: &rpc.Image{ + Repository: qcomp.Repository, + Tag: qcomp.Version, + }, + }) + } + + // TODO: pohfy, update report here comp := &rpc.ComponentUpgrade{ Status: status, Name: queue.Spec.Name, TeamName: c.teamName, - Image: &rpc.Image{Repository: queue.Spec.Repository, Tag: queue.Spec.Version}, + Components: rpcComps, IssueType: c.getIssueType(outImgList, queue), QueueHistoryName: queue.Status.QueueHistoryName, Namespace: queue.Namespace, diff --git a/internal/staging/deploy.go b/internal/staging/deploy.go index 146d4d86..5fcba7af 100644 --- a/internal/staging/deploy.go +++ b/internal/staging/deploy.go @@ -19,7 +19,6 @@ import ( "github.com/agoda-com/samsahai/internal/util/valuesutil" ) -// TODO: pohfy, update here // deployEnvironment deploy components into namespace func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { deployTimeout := metav1.Duration{Duration: 1800 * time.Second} @@ -57,12 +56,14 @@ func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { return err } + newComps := make([]*s2hv1beta1.QueueComponent, 0) for _, qcomp := range queue.Spec.Components { comp, ok := comps[qcomp.Name] if !ok { continue } + newComps = append(newComps, qcomp) queueComps[qcomp.Name] = comp queueParentComps[qcomp.Name] = comp @@ -71,12 +72,19 @@ func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { queueParentComps[comp.Parent] = comps[comp.Parent] } } + + // update queue if there are skipped components + if len(newComps) != len(queue.Spec.Components) { + queue.Spec.Components = newComps + if err := c.updateQueue(queue); err != nil { + return err + } + } } // Deploy if !queue.Status.IsConditionTrue(s2hv1beta1.QueueDeployStarted) { - // TODO: pohfy, fix here err := c.deployComponents(deployEngine, queue, queueComps, queueParentComps) if err != nil { return err diff --git a/pkg/samsahai/rpc/service.pb.go b/pkg/samsahai/rpc/service.pb.go index bbb65bcb..6925159e 100644 --- a/pkg/samsahai/rpc/service.pb.go +++ b/pkg/samsahai/rpc/service.pb.go @@ -1,24 +1,29 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0-devel +// protoc v3.9.1 // source: pkg/samsahai/rpc/service.proto package rpc import ( - fmt "fmt" proto "github.com/golang/protobuf/proto" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 type ComponentUpgrade_UpgradeStatus int32 @@ -27,22 +32,43 @@ const ( ComponentUpgrade_UpgradeStatus_SUCCESS ComponentUpgrade_UpgradeStatus = 1 ) -var ComponentUpgrade_UpgradeStatus_name = map[int32]string{ - 0: "UpgradeStatus_FAILURE", - 1: "UpgradeStatus_SUCCESS", -} +// Enum value maps for ComponentUpgrade_UpgradeStatus. +var ( + ComponentUpgrade_UpgradeStatus_name = map[int32]string{ + 0: "UpgradeStatus_FAILURE", + 1: "UpgradeStatus_SUCCESS", + } + ComponentUpgrade_UpgradeStatus_value = map[string]int32{ + "UpgradeStatus_FAILURE": 0, + "UpgradeStatus_SUCCESS": 1, + } +) -var ComponentUpgrade_UpgradeStatus_value = map[string]int32{ - "UpgradeStatus_FAILURE": 0, - "UpgradeStatus_SUCCESS": 1, +func (x ComponentUpgrade_UpgradeStatus) Enum() *ComponentUpgrade_UpgradeStatus { + p := new(ComponentUpgrade_UpgradeStatus) + *p = x + return p } func (x ComponentUpgrade_UpgradeStatus) String() string { - return proto.EnumName(ComponentUpgrade_UpgradeStatus_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ComponentUpgrade_UpgradeStatus) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_samsahai_rpc_service_proto_enumTypes[0].Descriptor() } +func (ComponentUpgrade_UpgradeStatus) Type() protoreflect.EnumType { + return &file_pkg_samsahai_rpc_service_proto_enumTypes[0] +} + +func (x ComponentUpgrade_UpgradeStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ComponentUpgrade_UpgradeStatus.Descriptor instead. func (ComponentUpgrade_UpgradeStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{2, 0} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 0} } type ComponentUpgrade_IssueType int32 @@ -54,26 +80,47 @@ const ( ComponentUpgrade_IssueType_ENVIRONMENT_ISSUE ComponentUpgrade_IssueType = 3 ) -var ComponentUpgrade_IssueType_name = map[int32]string{ - 0: "IssueType_UNKNOWN", - 1: "IssueType_DESIRED_VERSION_FAILED", - 2: "IssueType_IMAGE_MISSING", - 3: "IssueType_ENVIRONMENT_ISSUE", -} +// Enum value maps for ComponentUpgrade_IssueType. +var ( + ComponentUpgrade_IssueType_name = map[int32]string{ + 0: "IssueType_UNKNOWN", + 1: "IssueType_DESIRED_VERSION_FAILED", + 2: "IssueType_IMAGE_MISSING", + 3: "IssueType_ENVIRONMENT_ISSUE", + } + ComponentUpgrade_IssueType_value = map[string]int32{ + "IssueType_UNKNOWN": 0, + "IssueType_DESIRED_VERSION_FAILED": 1, + "IssueType_IMAGE_MISSING": 2, + "IssueType_ENVIRONMENT_ISSUE": 3, + } +) -var ComponentUpgrade_IssueType_value = map[string]int32{ - "IssueType_UNKNOWN": 0, - "IssueType_DESIRED_VERSION_FAILED": 1, - "IssueType_IMAGE_MISSING": 2, - "IssueType_ENVIRONMENT_ISSUE": 3, +func (x ComponentUpgrade_IssueType) Enum() *ComponentUpgrade_IssueType { + p := new(ComponentUpgrade_IssueType) + *p = x + return p } func (x ComponentUpgrade_IssueType) String() string { - return proto.EnumName(ComponentUpgrade_IssueType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ComponentUpgrade_IssueType) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_samsahai_rpc_service_proto_enumTypes[1].Descriptor() +} + +func (ComponentUpgrade_IssueType) Type() protoreflect.EnumType { + return &file_pkg_samsahai_rpc_service_proto_enumTypes[1] +} + +func (x ComponentUpgrade_IssueType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } +// Deprecated: Use ComponentUpgrade_IssueType.Descriptor instead. func (ComponentUpgrade_IssueType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{2, 1} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 1} } type ComponentUpgrade_ReverificationStatus int32 @@ -84,101 +131,141 @@ const ( ComponentUpgrade_ReverificationStatus_SUCCESS ComponentUpgrade_ReverificationStatus = 2 ) -var ComponentUpgrade_ReverificationStatus_name = map[int32]string{ - 0: "ReverificationStatus_UNKNOWN", - 1: "ReverificationStatus_FAILURE", - 2: "ReverificationStatus_SUCCESS", -} +// Enum value maps for ComponentUpgrade_ReverificationStatus. +var ( + ComponentUpgrade_ReverificationStatus_name = map[int32]string{ + 0: "ReverificationStatus_UNKNOWN", + 1: "ReverificationStatus_FAILURE", + 2: "ReverificationStatus_SUCCESS", + } + ComponentUpgrade_ReverificationStatus_value = map[string]int32{ + "ReverificationStatus_UNKNOWN": 0, + "ReverificationStatus_FAILURE": 1, + "ReverificationStatus_SUCCESS": 2, + } +) -var ComponentUpgrade_ReverificationStatus_value = map[string]int32{ - "ReverificationStatus_UNKNOWN": 0, - "ReverificationStatus_FAILURE": 1, - "ReverificationStatus_SUCCESS": 2, +func (x ComponentUpgrade_ReverificationStatus) Enum() *ComponentUpgrade_ReverificationStatus { + p := new(ComponentUpgrade_ReverificationStatus) + *p = x + return p } func (x ComponentUpgrade_ReverificationStatus) String() string { - return proto.EnumName(ComponentUpgrade_ReverificationStatus_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ComponentUpgrade_ReverificationStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{2, 2} +func (ComponentUpgrade_ReverificationStatus) Descriptor() protoreflect.EnumDescriptor { + return file_pkg_samsahai_rpc_service_proto_enumTypes[2].Descriptor() } -type Empty struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (ComponentUpgrade_ReverificationStatus) Type() protoreflect.EnumType { + return &file_pkg_samsahai_rpc_service_proto_enumTypes[2] } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{0} +func (x ComponentUpgrade_ReverificationStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -func (m *Empty) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Empty.Unmarshal(m, b) -} -func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Empty.Marshal(b, m, deterministic) +// Deprecated: Use ComponentUpgrade_ReverificationStatus.Descriptor instead. +func (ComponentUpgrade_ReverificationStatus) EnumDescriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 2} } -func (m *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(m, src) + +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func (m *Empty) XXX_Size() int { - return xxx_messageInfo_Empty.Size(m) + +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Empty) XXX_DiscardUnknown() { - xxx_messageInfo_Empty.DiscardUnknown(m) + +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Empty proto.InternalMessageInfo +func (*Empty) ProtoMessage() {} -type Team struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -func (m *Team) Reset() { *m = Team{} } -func (m *Team) String() string { return proto.CompactTextString(m) } -func (*Team) ProtoMessage() {} -func (*Team) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{1} +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{0} } -func (m *Team) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Team.Unmarshal(m, b) -} -func (m *Team) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Team.Marshal(b, m, deterministic) +type Team struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } -func (m *Team) XXX_Merge(src proto.Message) { - xxx_messageInfo_Team.Merge(m, src) + +func (x *Team) Reset() { + *x = Team{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Team) XXX_Size() int { - return xxx_messageInfo_Team.Size(m) + +func (x *Team) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Team) XXX_DiscardUnknown() { - xxx_messageInfo_Team.DiscardUnknown(m) + +func (*Team) ProtoMessage() {} + +func (x *Team) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -var xxx_messageInfo_Team proto.InternalMessageInfo +// Deprecated: Use Team.ProtoReflect.Descriptor instead. +func (*Team) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{1} +} -func (m *Team) GetName() string { - if m != nil { - return m.Name +func (x *Team) GetName() string { + if x != nil { + return x.Name } return "" } type ComponentUpgrade struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Status ComponentUpgrade_UpgradeStatus `protobuf:"varint,1,opt,name=status,proto3,enum=samsahai.io.samsahai.ComponentUpgrade_UpgradeStatus" json:"status,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` TeamName string `protobuf:"bytes,3,opt,name=teamName,proto3" json:"teamName,omitempty"` - Image *Image `protobuf:"bytes,4,opt,name=image,proto3" json:"image,omitempty"` + Components []*Component `protobuf:"bytes,4,rep,name=components,proto3" json:"components,omitempty"` IssueType ComponentUpgrade_IssueType `protobuf:"varint,5,opt,name=issueType,proto3,enum=samsahai.io.samsahai.ComponentUpgrade_IssueType" json:"issueType,omitempty"` QueueHistoryName string `protobuf:"bytes,6,opt,name=queueHistoryName,proto3" json:"queueHistoryName,omitempty"` ImageMissingList []*Image `protobuf:"bytes,7,rep,name=imageMissingList,proto3" json:"imageMissingList,omitempty"` @@ -187,318 +274,614 @@ type ComponentUpgrade struct { Runs int32 `protobuf:"varint,10,opt,name=runs,proto3" json:"runs,omitempty"` IsReverify bool `protobuf:"varint,11,opt,name=isReverify,proto3" json:"isReverify,omitempty"` ReverificationStatus ComponentUpgrade_ReverificationStatus `protobuf:"varint,12,opt,name=reverificationStatus,proto3,enum=samsahai.io.samsahai.ComponentUpgrade_ReverificationStatus" json:"reverificationStatus,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` } -func (m *ComponentUpgrade) Reset() { *m = ComponentUpgrade{} } -func (m *ComponentUpgrade) String() string { return proto.CompactTextString(m) } -func (*ComponentUpgrade) ProtoMessage() {} -func (*ComponentUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{2} +func (x *ComponentUpgrade) Reset() { + *x = ComponentUpgrade{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ComponentUpgrade) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ComponentUpgrade.Unmarshal(m, b) -} -func (m *ComponentUpgrade) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ComponentUpgrade.Marshal(b, m, deterministic) -} -func (m *ComponentUpgrade) XXX_Merge(src proto.Message) { - xxx_messageInfo_ComponentUpgrade.Merge(m, src) +func (x *ComponentUpgrade) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ComponentUpgrade) XXX_Size() int { - return xxx_messageInfo_ComponentUpgrade.Size(m) -} -func (m *ComponentUpgrade) XXX_DiscardUnknown() { - xxx_messageInfo_ComponentUpgrade.DiscardUnknown(m) + +func (*ComponentUpgrade) ProtoMessage() {} + +func (x *ComponentUpgrade) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -var xxx_messageInfo_ComponentUpgrade proto.InternalMessageInfo +// Deprecated: Use ComponentUpgrade.ProtoReflect.Descriptor instead. +func (*ComponentUpgrade) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2} +} -func (m *ComponentUpgrade) GetStatus() ComponentUpgrade_UpgradeStatus { - if m != nil { - return m.Status +func (x *ComponentUpgrade) GetStatus() ComponentUpgrade_UpgradeStatus { + if x != nil { + return x.Status } return ComponentUpgrade_UpgradeStatus_FAILURE } -func (m *ComponentUpgrade) GetName() string { - if m != nil { - return m.Name +func (x *ComponentUpgrade) GetName() string { + if x != nil { + return x.Name } return "" } -func (m *ComponentUpgrade) GetTeamName() string { - if m != nil { - return m.TeamName +func (x *ComponentUpgrade) GetTeamName() string { + if x != nil { + return x.TeamName } return "" } -func (m *ComponentUpgrade) GetImage() *Image { - if m != nil { - return m.Image +func (x *ComponentUpgrade) GetComponents() []*Component { + if x != nil { + return x.Components } return nil } -func (m *ComponentUpgrade) GetIssueType() ComponentUpgrade_IssueType { - if m != nil { - return m.IssueType +func (x *ComponentUpgrade) GetIssueType() ComponentUpgrade_IssueType { + if x != nil { + return x.IssueType } return ComponentUpgrade_IssueType_UNKNOWN } -func (m *ComponentUpgrade) GetQueueHistoryName() string { - if m != nil { - return m.QueueHistoryName +func (x *ComponentUpgrade) GetQueueHistoryName() string { + if x != nil { + return x.QueueHistoryName } return "" } -func (m *ComponentUpgrade) GetImageMissingList() []*Image { - if m != nil { - return m.ImageMissingList +func (x *ComponentUpgrade) GetImageMissingList() []*Image { + if x != nil { + return x.ImageMissingList } return nil } -func (m *ComponentUpgrade) GetNamespace() string { - if m != nil { - return m.Namespace +func (x *ComponentUpgrade) GetNamespace() string { + if x != nil { + return x.Namespace } return "" } -func (m *ComponentUpgrade) GetTestBuildTypeID() string { - if m != nil { - return m.TestBuildTypeID +func (x *ComponentUpgrade) GetTestBuildTypeID() string { + if x != nil { + return x.TestBuildTypeID } return "" } -func (m *ComponentUpgrade) GetRuns() int32 { - if m != nil { - return m.Runs +func (x *ComponentUpgrade) GetRuns() int32 { + if x != nil { + return x.Runs } return 0 } -func (m *ComponentUpgrade) GetIsReverify() bool { - if m != nil { - return m.IsReverify +func (x *ComponentUpgrade) GetIsReverify() bool { + if x != nil { + return x.IsReverify } return false } -func (m *ComponentUpgrade) GetReverificationStatus() ComponentUpgrade_ReverificationStatus { - if m != nil { - return m.ReverificationStatus +func (x *ComponentUpgrade) GetReverificationStatus() ComponentUpgrade_ReverificationStatus { + if x != nil { + return x.ReverificationStatus } return ComponentUpgrade_ReverificationStatus_UNKNOWN } -type Image struct { - Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` - Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type Component struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Image *Image `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` } -func (m *Image) Reset() { *m = Image{} } -func (m *Image) String() string { return proto.CompactTextString(m) } -func (*Image) ProtoMessage() {} -func (*Image) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{3} +func (x *Component) Reset() { + *x = Component{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Image) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Image.Unmarshal(m, b) +func (x *Component) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Image) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Image.Marshal(b, m, deterministic) + +func (*Component) ProtoMessage() {} + +func (x *Component) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -func (m *Image) XXX_Merge(src proto.Message) { - xxx_messageInfo_Image.Merge(m, src) + +// Deprecated: Use Component.ProtoReflect.Descriptor instead. +func (*Component) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3} } -func (m *Image) XXX_Size() int { - return xxx_messageInfo_Image.Size(m) + +func (x *Component) GetName() string { + if x != nil { + return x.Name + } + return "" } -func (m *Image) XXX_DiscardUnknown() { - xxx_messageInfo_Image.DiscardUnknown(m) + +func (x *Component) GetImage() *Image { + if x != nil { + return x.Image + } + return nil } -var xxx_messageInfo_Image proto.InternalMessageInfo +type Image struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Image) GetRepository() string { - if m != nil { - return m.Repository + Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *Image) Reset() { + *x = Image{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" } -func (m *Image) GetTag() string { - if m != nil { - return m.Tag +func (x *Image) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Image) ProtoMessage() {} + +func (x *Image) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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 "" + return mi.MessageOf(x) } -type ImageList struct { - Images []*Image `protobuf:"bytes,1,rep,name=images,proto3" json:"images,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +// Deprecated: Use Image.ProtoReflect.Descriptor instead. +func (*Image) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{4} } -func (m *ImageList) Reset() { *m = ImageList{} } -func (m *ImageList) String() string { return proto.CompactTextString(m) } -func (*ImageList) ProtoMessage() {} -func (*ImageList) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{4} +func (x *Image) GetRepository() string { + if x != nil { + return x.Repository + } + return "" } -func (m *ImageList) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ImageList.Unmarshal(m, b) +func (x *Image) GetTag() string { + if x != nil { + return x.Tag + } + return "" } -func (m *ImageList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ImageList.Marshal(b, m, deterministic) + +type ImageList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Images []*Image `protobuf:"bytes,1,rep,name=images,proto3" json:"images,omitempty"` } -func (m *ImageList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ImageList.Merge(m, src) + +func (x *ImageList) Reset() { + *x = ImageList{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ImageList) XXX_Size() int { - return xxx_messageInfo_ImageList.Size(m) + +func (x *ImageList) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ImageList) XXX_DiscardUnknown() { - xxx_messageInfo_ImageList.DiscardUnknown(m) + +func (*ImageList) ProtoMessage() {} + +func (x *ImageList) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -var xxx_messageInfo_ImageList proto.InternalMessageInfo +// Deprecated: Use ImageList.ProtoReflect.Descriptor instead. +func (*ImageList) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{5} +} -func (m *ImageList) GetImages() []*Image { - if m != nil { - return m.Images +func (x *ImageList) GetImages() []*Image { + if x != nil { + return x.Images } return nil } type TeamWithCurrentComponent struct { - TeamName string `protobuf:"bytes,1,opt,name=teamName,proto3" json:"teamName,omitempty"` - CompName string `protobuf:"bytes,2,opt,name=compName,proto3" json:"compName,omitempty"` - Image *Image `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *TeamWithCurrentComponent) Reset() { *m = TeamWithCurrentComponent{} } -func (m *TeamWithCurrentComponent) String() string { return proto.CompactTextString(m) } -func (*TeamWithCurrentComponent) ProtoMessage() {} -func (*TeamWithCurrentComponent) Descriptor() ([]byte, []int) { - return fileDescriptor_bb42a50bcb57dea2, []int{5} + TeamName string `protobuf:"bytes,1,opt,name=teamName,proto3" json:"teamName,omitempty"` + CompName string `protobuf:"bytes,2,opt,name=compName,proto3" json:"compName,omitempty"` + Image *Image `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"` } -func (m *TeamWithCurrentComponent) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TeamWithCurrentComponent.Unmarshal(m, b) -} -func (m *TeamWithCurrentComponent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TeamWithCurrentComponent.Marshal(b, m, deterministic) -} -func (m *TeamWithCurrentComponent) XXX_Merge(src proto.Message) { - xxx_messageInfo_TeamWithCurrentComponent.Merge(m, src) +func (x *TeamWithCurrentComponent) Reset() { + *x = TeamWithCurrentComponent{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *TeamWithCurrentComponent) XXX_Size() int { - return xxx_messageInfo_TeamWithCurrentComponent.Size(m) + +func (x *TeamWithCurrentComponent) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *TeamWithCurrentComponent) XXX_DiscardUnknown() { - xxx_messageInfo_TeamWithCurrentComponent.DiscardUnknown(m) + +func (*TeamWithCurrentComponent) ProtoMessage() {} + +func (x *TeamWithCurrentComponent) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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) } -var xxx_messageInfo_TeamWithCurrentComponent proto.InternalMessageInfo +// Deprecated: Use TeamWithCurrentComponent.ProtoReflect.Descriptor instead. +func (*TeamWithCurrentComponent) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{6} +} -func (m *TeamWithCurrentComponent) GetTeamName() string { - if m != nil { - return m.TeamName +func (x *TeamWithCurrentComponent) GetTeamName() string { + if x != nil { + return x.TeamName } return "" } -func (m *TeamWithCurrentComponent) GetCompName() string { - if m != nil { - return m.CompName +func (x *TeamWithCurrentComponent) GetCompName() string { + if x != nil { + return x.CompName } return "" } -func (m *TeamWithCurrentComponent) GetImage() *Image { - if m != nil { - return m.Image +func (x *TeamWithCurrentComponent) GetImage() *Image { + if x != nil { + return x.Image } return nil } -func init() { - proto.RegisterEnum("samsahai.io.samsahai.ComponentUpgrade_UpgradeStatus", ComponentUpgrade_UpgradeStatus_name, ComponentUpgrade_UpgradeStatus_value) - proto.RegisterEnum("samsahai.io.samsahai.ComponentUpgrade_IssueType", ComponentUpgrade_IssueType_name, ComponentUpgrade_IssueType_value) - proto.RegisterEnum("samsahai.io.samsahai.ComponentUpgrade_ReverificationStatus", ComponentUpgrade_ReverificationStatus_name, ComponentUpgrade_ReverificationStatus_value) - proto.RegisterType((*Empty)(nil), "samsahai.io.samsahai.Empty") - proto.RegisterType((*Team)(nil), "samsahai.io.samsahai.Team") - proto.RegisterType((*ComponentUpgrade)(nil), "samsahai.io.samsahai.ComponentUpgrade") - proto.RegisterType((*Image)(nil), "samsahai.io.samsahai.Image") - proto.RegisterType((*ImageList)(nil), "samsahai.io.samsahai.ImageList") - proto.RegisterType((*TeamWithCurrentComponent)(nil), "samsahai.io.samsahai.TeamWithCurrentComponent") -} - -func init() { proto.RegisterFile("pkg/samsahai/rpc/service.proto", fileDescriptor_bb42a50bcb57dea2) } - -var fileDescriptor_bb42a50bcb57dea2 = []byte{ - // 682 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xae, 0x93, 0x26, 0x4d, 0xa6, 0xbf, 0x1f, 0xb8, 0xab, 0x56, 0x35, 0x69, 0xd5, 0x5a, 0x16, - 0x42, 0x11, 0x07, 0x17, 0x5a, 0x2e, 0x88, 0x0b, 0x6d, 0x62, 0x82, 0x45, 0xe3, 0x96, 0x75, 0xd3, - 0x4a, 0x1c, 0x88, 0x16, 0x67, 0x49, 0x57, 0xe0, 0x3f, 0xec, 0xae, 0x2b, 0x45, 0xe2, 0x0a, 0x8f, - 0xc3, 0x4b, 0xf0, 0x62, 0xc8, 0xdb, 0x24,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xf7, 0x9c, 0x72, 0xc1, 0xe2, 0x08, 0xd9, 0xc5, - 0x11, 0xf3, 0xea, 0xd2, 0xd8, 0xfd, 0xcb, 0x85, 0xd4, 0x53, 0x10, 0x68, 0xf8, 0x34, 0x1a, 0xf4, - 0x92, 0x01, 0x91, 0x4a, 0xf7, 0xf4, 0x7d, 0x36, 0x79, 0xba, 0x54, 0x72, 0x16, 0xfc, 0x93, 0x8b, - 0x1c, 0x55, 0x3e, 0x94, 0x79, 0x12, 0x7c, 0xaa, 0xaa, 0x9f, 0xc8, 0xc1, 0x9f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x22, 0xec, 0x2a, 0x56, 0x66, 0x06, 0x00, 0x00, +var File_pkg_samsahai_rpc_service_proto protoreflect.FileDescriptor + +var file_pkg_samsahai_rpc_service_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2f, 0x72, + 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x14, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, + 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x1a, 0x0a, 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xd1, 0x07, 0x0a, 0x10, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, + 0x12, 0x4c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x34, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3f, + 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, + 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, + 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, + 0x4e, 0x0a, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, + 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, + 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x2a, 0x0a, 0x10, 0x71, 0x75, 0x65, 0x75, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x71, 0x75, 0x65, 0x75, 0x65, + 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x10, 0x69, + 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x18, + 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x52, 0x10, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, + 0x79, 0x70, 0x65, 0x49, 0x44, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, 0x73, + 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, + 0x72, 0x75, 0x6e, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x75, 0x6e, 0x73, + 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, + 0x12, 0x6f, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, + 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, + 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x14, 0x72, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x45, 0x0a, 0x0d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x00, 0x12, 0x19, 0x0a, + 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x53, + 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x22, 0x86, 0x01, 0x0a, 0x09, 0x49, 0x73, 0x73, + 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x24, 0x0a, + 0x20, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x44, 0x45, 0x53, 0x49, 0x52, + 0x45, 0x44, 0x5f, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, + 0x44, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x02, + 0x12, 0x1f, 0x0a, 0x1b, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x45, 0x4e, + 0x56, 0x49, 0x52, 0x4f, 0x4e, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, + 0x03, 0x22, 0x7c, 0x0a, 0x14, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x1c, 0x52, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x52, + 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x01, 0x12, 0x20, 0x0a, + 0x1c, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, 0x22, + 0x52, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x31, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, + 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x05, 0x69, 0x6d, + 0x61, 0x67, 0x65, 0x22, 0x39, 0x0a, 0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, + 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x40, + 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x06, 0x69, + 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, + 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, + 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x06, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, + 0x22, 0x85, 0x01, 0x0a, 0x18, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, + 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, + 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, + 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, + 0x65, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x32, 0xae, 0x02, 0x0a, 0x03, 0x52, 0x50, 0x43, + 0x12, 0x5e, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x26, 0x2e, 0x73, 0x61, + 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, + 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, + 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, + 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x12, 0x64, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, 0x61, + 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x53, 0x65, 0x6e, 0x64, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, 0x4d, 0x65, + 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, + 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, + 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, 0x63, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_pkg_samsahai_rpc_service_proto_rawDescOnce sync.Once + file_pkg_samsahai_rpc_service_proto_rawDescData = file_pkg_samsahai_rpc_service_proto_rawDesc +) + +func file_pkg_samsahai_rpc_service_proto_rawDescGZIP() []byte { + file_pkg_samsahai_rpc_service_proto_rawDescOnce.Do(func() { + file_pkg_samsahai_rpc_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_samsahai_rpc_service_proto_rawDescData) + }) + return file_pkg_samsahai_rpc_service_proto_rawDescData +} + +var file_pkg_samsahai_rpc_service_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_pkg_samsahai_rpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_pkg_samsahai_rpc_service_proto_goTypes = []interface{}{ + (ComponentUpgrade_UpgradeStatus)(0), // 0: samsahai.io.samsahai.ComponentUpgrade.UpgradeStatus + (ComponentUpgrade_IssueType)(0), // 1: samsahai.io.samsahai.ComponentUpgrade.IssueType + (ComponentUpgrade_ReverificationStatus)(0), // 2: samsahai.io.samsahai.ComponentUpgrade.ReverificationStatus + (*Empty)(nil), // 3: samsahai.io.samsahai.Empty + (*Team)(nil), // 4: samsahai.io.samsahai.Team + (*ComponentUpgrade)(nil), // 5: samsahai.io.samsahai.ComponentUpgrade + (*Component)(nil), // 6: samsahai.io.samsahai.Component + (*Image)(nil), // 7: samsahai.io.samsahai.Image + (*ImageList)(nil), // 8: samsahai.io.samsahai.ImageList + (*TeamWithCurrentComponent)(nil), // 9: samsahai.io.samsahai.TeamWithCurrentComponent +} +var file_pkg_samsahai_rpc_service_proto_depIdxs = []int32{ + 0, // 0: samsahai.io.samsahai.ComponentUpgrade.status:type_name -> samsahai.io.samsahai.ComponentUpgrade.UpgradeStatus + 6, // 1: samsahai.io.samsahai.ComponentUpgrade.components:type_name -> samsahai.io.samsahai.Component + 1, // 2: samsahai.io.samsahai.ComponentUpgrade.issueType:type_name -> samsahai.io.samsahai.ComponentUpgrade.IssueType + 7, // 3: samsahai.io.samsahai.ComponentUpgrade.imageMissingList:type_name -> samsahai.io.samsahai.Image + 2, // 4: samsahai.io.samsahai.ComponentUpgrade.reverificationStatus:type_name -> samsahai.io.samsahai.ComponentUpgrade.ReverificationStatus + 7, // 5: samsahai.io.samsahai.Component.image:type_name -> samsahai.io.samsahai.Image + 7, // 6: samsahai.io.samsahai.ImageList.images:type_name -> samsahai.io.samsahai.Image + 7, // 7: samsahai.io.samsahai.TeamWithCurrentComponent.image:type_name -> samsahai.io.samsahai.Image + 5, // 8: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:input_type -> samsahai.io.samsahai.ComponentUpgrade + 9, // 9: samsahai.io.samsahai.RPC.GetMissingVersion:input_type -> samsahai.io.samsahai.TeamWithCurrentComponent + 5, // 10: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:input_type -> samsahai.io.samsahai.ComponentUpgrade + 3, // 11: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:output_type -> samsahai.io.samsahai.Empty + 8, // 12: samsahai.io.samsahai.RPC.GetMissingVersion:output_type -> samsahai.io.samsahai.ImageList + 3, // 13: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:output_type -> samsahai.io.samsahai.Empty + 11, // [11:14] is the sub-list for method output_type + 8, // [8:11] 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_pkg_samsahai_rpc_service_proto_init() } +func file_pkg_samsahai_rpc_service_proto_init() { + if File_pkg_samsahai_rpc_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_samsahai_rpc_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Team); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentUpgrade); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Component); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Image); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ImageList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TeamWithCurrentComponent); 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_pkg_samsahai_rpc_service_proto_rawDesc, + NumEnums: 3, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_samsahai_rpc_service_proto_goTypes, + DependencyIndexes: file_pkg_samsahai_rpc_service_proto_depIdxs, + EnumInfos: file_pkg_samsahai_rpc_service_proto_enumTypes, + MessageInfos: file_pkg_samsahai_rpc_service_proto_msgTypes, + }.Build() + File_pkg_samsahai_rpc_service_proto = out.File + file_pkg_samsahai_rpc_service_proto_rawDesc = nil + file_pkg_samsahai_rpc_service_proto_goTypes = nil + file_pkg_samsahai_rpc_service_proto_depIdxs = nil } diff --git a/pkg/samsahai/rpc/service.proto b/pkg/samsahai/rpc/service.proto index f298ab3b..d3045cdd 100644 --- a/pkg/samsahai/rpc/service.proto +++ b/pkg/samsahai/rpc/service.proto @@ -35,7 +35,7 @@ message ComponentUpgrade { UpgradeStatus status = 1; string name = 2; string teamName = 3; - Image image = 4; + repeated Component components = 4; IssueType issueType = 5; string queueHistoryName = 6; repeated Image imageMissingList = 7; @@ -46,6 +46,11 @@ message ComponentUpgrade { ReverificationStatus reverificationStatus = 12; } +message Component { + string name = 1; + Image image = 2; +} + message Image { string repository = 1; string tag = 2; diff --git a/pkg/samsahai/rpc/service.twirp.go b/pkg/samsahai/rpc/service.twirp.go index ebd0f568..f699f098 100644 --- a/pkg/samsahai/rpc/service.twirp.go +++ b/pkg/samsahai/rpc/service.twirp.go @@ -1,9 +1,9 @@ -// Code generated by protoc-gen-twirp v5.10.1, DO NOT EDIT. +// Code generated by protoc-gen-twirp v5.10.2, DO NOT EDIT. // source: pkg/samsahai/rpc/service.proto /* Package rpc is a generated twirp stub package. -This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.1. +This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.2. It is generated from these files: pkg/samsahai/rpc/service.proto @@ -689,7 +689,7 @@ func (s *rPCServer) ServiceDescriptor() ([]byte, int) { } func (s *rPCServer) ProtocGenTwirpVersion() string { - return "v5.10.1" + return "v5.10.2" } func (s *rPCServer) PathPrefix() string { @@ -830,7 +830,7 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType } req.Header.Set("Accept", contentType) req.Header.Set("Content-Type", contentType) - req.Header.Set("Twirp-Version", "v5.10.1") + req.Header.Set("Twirp-Version", "v5.10.2") return req, nil } @@ -898,7 +898,7 @@ func errorFromResponse(resp *http.Response) twirp.Error { errorCode := twirp.ErrorCode(tj.Code) if !twirp.IsValidErrorCode(errorCode) { msg := "invalid type returned from server error response: " + tj.Code - return twirp.InternalError(msg) + return twirp.InternalError(msg).WithMeta("body", string(respBodyBytes)) } twerr := twirp.NewError(errorCode, tj.Msg) @@ -1209,48 +1209,49 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 682 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xae, 0x93, 0x26, 0x4d, 0xa6, 0xbf, 0x1f, 0xb8, 0xab, 0x56, 0x35, 0x69, 0xd5, 0x5a, 0x16, - 0x42, 0x11, 0x07, 0x17, 0x5a, 0x2e, 0x88, 0x0b, 0x6d, 0x62, 0x82, 0x45, 0xe3, 0x96, 0x75, 0xd3, - 0x4a, 0x1c, 0x88, 0x16, 0x67, 0x49, 0x57, 0xe0, 0x3f, 0xec, 0xae, 0x2b, 0x45, 0xe2, 0x0a, 0x8f, - 0xc3, 0x4b, 0xf0, 0x62, 0xc8, 0xdb, 0x24, 0x6e, 0x1b, 0x87, 0xe6, 0xc0, 0xc9, 0xb3, 0xd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 0x11, 0xf3, 0xea, 0xd2, 0xd8, 0xfd, 0xcb, 0x85, 0xd4, 0x53, 0x10, 0x68, 0xf8, 0x34, 0x1a, 0xf4, - 0x92, 0x01, 0x91, 0x4a, 0xf7, 0xf4, 0x7d, 0x36, 0x79, 0xba, 0x54, 0x72, 0x16, 0xfc, 0x93, 0x8b, - 0x1c, 0x55, 0x3e, 0x94, 0x79, 0x12, 0x7c, 0xaa, 0xaa, 0x9f, 0xc8, 0xc1, 0x9f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x22, 0xec, 0x2a, 0x56, 0x66, 0x06, 0x00, 0x00, + // 699 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x4e, 0x13, 0x41, + 0x14, 0x66, 0x5b, 0x5a, 0xda, 0x83, 0x3f, 0xcb, 0x04, 0xc2, 0x5a, 0x08, 0x34, 0x1b, 0x63, 0x1a, + 0x2f, 0x16, 0x05, 0x6f, 0x8c, 0x17, 0x0a, 0xed, 0x5a, 0x37, 0xd2, 0x05, 0x67, 0x29, 0x24, 0x5e, + 0xd8, 0x8c, 0xdb, 0xb1, 0x4c, 0x74, 0x7f, 0x9c, 0x99, 0x25, 0x69, 0xe2, 0xad, 0x3e, 0x8e, 0xef, + 0xe2, 0x1b, 0x99, 0x1d, 0xda, 0x6e, 0xa1, 0x5b, 0xe9, 0x85, 0x57, 0x7b, 0xe6, 0x9b, 0xf3, 0x3f, + 0xe7, 0x7c, 0x0b, 0x3b, 0xf1, 0xd7, 0xc1, 0x9e, 0x20, 0x81, 0x20, 0x97, 0x84, 0xed, 0xf1, 0xd8, + 0xdf, 0x13, 0x94, 0x5f, 0x31, 0x9f, 0x5a, 0x31, 0x8f, 0x64, 0x84, 0xd6, 0xc7, 0x77, 0x16, 0x8b, + 0xac, 0xb1, 0x6c, 0xae, 0x40, 0xc9, 0x0e, 0x62, 0x39, 0x34, 0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b6, 0xf3, 0xf0, 0xa9, 0xec, 0xe6, 0x69, 0x8c, 0xeb, 0xd7, 0xe6, 0x6a, + 0x8c, 0xdb, 0x50, 0x30, 0x31, 0x54, 0x27, 0x8f, 0x91, 0xb7, 0xf4, 0xe8, 0x39, 0x94, 0xd4, 0xbc, + 0xa9, 0x95, 0xbc, 0x63, 0x32, 0xaf, 0x35, 0xcd, 0x97, 0x50, 0x52, 0xe7, 0x74, 0x76, 0x38, 0x8d, + 0x23, 0xc1, 0xd2, 0x91, 0x1f, 0x79, 0x9d, 0x42, 0x90, 0x0e, 0x45, 0x49, 0x06, 0xa3, 0x65, 0x4f, + 0x45, 0xf3, 0x0d, 0x54, 0x95, 0xa9, 0x1a, 0xeb, 0x03, 0x28, 0x2b, 0x87, 0x29, 0xb5, 0xdc, 0xb9, + 0x15, 0x23, 0x55, 0xf3, 0xa7, 0x06, 0x46, 0xca, 0x60, 0x17, 0x4c, 0x5e, 0x36, 0x13, 0xce, 0x69, + 0x28, 0xb3, 0x02, 0xa7, 0xa9, 0x44, 0xbb, 0x45, 0x25, 0x35, 0xa8, 0xa4, 0xbc, 0xe0, 0x66, 0xf4, + 0x33, 0x39, 0x67, 0x4d, 0x28, 0x2e, 0xda, 0x84, 0xfd, 0xdf, 0x05, 0x28, 0xe2, 0xd3, 0x26, 0xfa, + 0x04, 0x9b, 0x38, 0x09, 0x4f, 0x23, 0x21, 0x67, 0xa8, 0xf3, 0xc9, 0x62, 0xcb, 0x51, 0x9b, 0x13, + 0x4e, 0x11, 0x36, 0xea, 0xc3, 0x5a, 0x9b, 0xca, 0x11, 0x1b, 0x9c, 0x53, 0x2e, 0x58, 0x14, 0x22, + 0x2b, 0xdf, 0x62, 0x5e, 0x5f, 0x6a, 0xbb, 0xff, 0x28, 0x48, 0x3d, 0x05, 0x81, 0x9a, 0x47, 0xc3, + 0x7e, 0x37, 0xee, 0x13, 0xa9, 0x76, 0x89, 0x7e, 0x48, 0xd9, 0xac, 0x43, 0x25, 0x67, 0xfe, 0x7f, + 0x29, 0xe4, 0xa8, 0xf4, 0xb1, 0xc8, 0x63, 0xff, 0x73, 0x59, 0xfd, 0xa6, 0x0e, 0xfe, 0x06, 0x00, + 0x00, 0xff, 0xff, 0x54, 0x04, 0x58, 0x1e, 0xc8, 0x06, 0x00, 0x00, } diff --git a/pkg/staging/rpc/service.pb.go b/pkg/staging/rpc/service.pb.go index 8ba6a399..242bd7fb 100644 --- a/pkg/staging/rpc/service.pb.go +++ b/pkg/staging/rpc/service.pb.go @@ -1,69 +1,138 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0-devel +// protoc v3.9.1 // source: pkg/staging/rpc/service.proto package rpc import ( - fmt "fmt" proto "github.com/golang/protobuf/proto" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 type Empty struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_3896b0de76041e06, []int{0} +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_staging_rpc_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Empty) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Empty.Unmarshal(m, b) +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Empty.Marshal(b, m, deterministic) -} -func (m *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(m, src) + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_pkg_staging_rpc_service_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) } -func (m *Empty) XXX_Size() int { - return xxx_messageInfo_Empty.Size(m) + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_pkg_staging_rpc_service_proto_rawDescGZIP(), []int{0} } -func (m *Empty) XXX_DiscardUnknown() { - xxx_messageInfo_Empty.DiscardUnknown(m) + +var File_pkg_staging_rpc_service_proto protoreflect.FileDescriptor + +var file_pkg_staging_rpc_service_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x70, + 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x13, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x74, 0x61, + 0x67, 0x69, 0x6e, 0x67, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x05, 0x0a, + 0x03, 0x52, 0x50, 0x43, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } -var xxx_messageInfo_Empty proto.InternalMessageInfo +var ( + file_pkg_staging_rpc_service_proto_rawDescOnce sync.Once + file_pkg_staging_rpc_service_proto_rawDescData = file_pkg_staging_rpc_service_proto_rawDesc +) + +func file_pkg_staging_rpc_service_proto_rawDescGZIP() []byte { + file_pkg_staging_rpc_service_proto_rawDescOnce.Do(func() { + file_pkg_staging_rpc_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_staging_rpc_service_proto_rawDescData) + }) + return file_pkg_staging_rpc_service_proto_rawDescData +} -func init() { - proto.RegisterType((*Empty)(nil), "samsahai.io.staging.Empty") +var file_pkg_staging_rpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_pkg_staging_rpc_service_proto_goTypes = []interface{}{ + (*Empty)(nil), // 0: samsahai.io.staging.Empty +} +var file_pkg_staging_rpc_service_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() { proto.RegisterFile("pkg/staging/rpc/service.proto", fileDescriptor_3896b0de76041e06) } - -var fileDescriptor_3896b0de76041e06 = []byte{ - // 99 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0x4e, 0xd7, - 0x2f, 0x2e, 0x49, 0x4c, 0xcf, 0xcc, 0x4b, 0xd7, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x4e, 0x2d, 0x2a, - 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0x2d, 0x4e, - 0xcc, 0x48, 0xcc, 0xd4, 0xcb, 0xcc, 0xd7, 0x83, 0x2a, 0x53, 0x62, 0xe7, 0x62, 0x75, 0xcd, 0x2d, - 0x28, 0xa9, 0x34, 0x62, 0xe5, 0x62, 0x0e, 0x0a, 0x70, 0x76, 0x62, 0x8d, 0x62, 0x2e, 0x2a, 0x48, - 0x4e, 0x62, 0x03, 0x6b, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x04, 0xa0, 0x3d, 0xa6, 0x53, - 0x00, 0x00, 0x00, +func init() { file_pkg_staging_rpc_service_proto_init() } +func file_pkg_staging_rpc_service_proto_init() { + if File_pkg_staging_rpc_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_staging_rpc_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); 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_pkg_staging_rpc_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_staging_rpc_service_proto_goTypes, + DependencyIndexes: file_pkg_staging_rpc_service_proto_depIdxs, + MessageInfos: file_pkg_staging_rpc_service_proto_msgTypes, + }.Build() + File_pkg_staging_rpc_service_proto = out.File + file_pkg_staging_rpc_service_proto_rawDesc = nil + file_pkg_staging_rpc_service_proto_goTypes = nil + file_pkg_staging_rpc_service_proto_depIdxs = nil } diff --git a/pkg/staging/rpc/service.twirp.go b/pkg/staging/rpc/service.twirp.go index 7658fb5e..0cf5833b 100644 --- a/pkg/staging/rpc/service.twirp.go +++ b/pkg/staging/rpc/service.twirp.go @@ -1,9 +1,9 @@ -// Code generated by protoc-gen-twirp v5.10.1, DO NOT EDIT. +// Code generated by protoc-gen-twirp v5.10.2, DO NOT EDIT. // source: pkg/staging/rpc/service.proto /* Package rpc is a generated twirp stub package. -This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.1. +This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.2. It is generated from these files: pkg/staging/rpc/service.proto @@ -157,7 +157,7 @@ func (s *rPCServer) ServiceDescriptor() ([]byte, int) { } func (s *rPCServer) ProtocGenTwirpVersion() string { - return "v5.10.1" + return "v5.10.2" } func (s *rPCServer) PathPrefix() string { @@ -298,7 +298,7 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType } req.Header.Set("Accept", contentType) req.Header.Set("Content-Type", contentType) - req.Header.Set("Twirp-Version", "v5.10.1") + req.Header.Set("Twirp-Version", "v5.10.2") return req, nil } @@ -366,7 +366,7 @@ func errorFromResponse(resp *http.Response) twirp.Error { errorCode := twirp.ErrorCode(tj.Code) if !twirp.IsValidErrorCode(errorCode) { msg := "invalid type returned from server error response: " + tj.Code - return twirp.InternalError(msg) + return twirp.InternalError(msg).WithMeta("body", string(respBodyBytes)) } twerr := twirp.NewError(errorCode, tj.Msg) From 2a1b51f9b6160d7ce1fb4c8be1b5fb990aaafb56 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Wed, 3 Jun 2020 15:19:59 +0700 Subject: [PATCH 04/12] :bento: Update image missing list --- internal/reporter/msteams/reporter.go | 2 +- internal/samsahai/rpc.go | 21 +++++-- internal/staging/image_missing.go | 19 ++++-- pkg/samsahai/rpc/service.pb.go | 73 ++++++++++------------ pkg/samsahai/rpc/service.proto | 3 +- pkg/samsahai/rpc/service.twirp.go | 89 +++++++++++++-------------- 6 files changed, 106 insertions(+), 101 deletions(-) diff --git a/internal/reporter/msteams/reporter.go b/internal/reporter/msteams/reporter.go index bb3ccdd7..fd15472f 100644 --- a/internal/reporter/msteams/reporter.go +++ b/internal/reporter/msteams/reporter.go @@ -202,7 +202,7 @@ func (r *reporter) makeComponentUpgradeReport(comp *internal.ComponentUpgradeRep message := ` Component Upgrade: Success {{ else }}` + styleDanger + `> Failure{{ end }} {{- if eq .Status 0 }} -Issue type: {{ .IssueTypeStr }} +
    Issue type: {{ .IssueTypeStr }} {{- end }}
    Run:{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }}
    Components diff --git a/internal/samsahai/rpc.go b/internal/samsahai/rpc.go index ab19fa77..72ad47cb 100644 --- a/internal/samsahai/rpc.go +++ b/internal/samsahai/rpc.go @@ -30,7 +30,6 @@ func (c *controller) authenticateRPC(ctx context.Context) error { return nil } -// TODO: pohfy, TeamWithCurrentComponents func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWithCurrentComponent) (*rpc.ImageList, error) { if err := c.authenticateRPC(ctx); err != nil { return nil, err @@ -60,6 +59,7 @@ func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWi return nil, errors.Wrapf(err, "cannot get components of team %s", teamComp.Name) } + // get image missing of stable components for _, stable := range stableList.Items { source, ok := c.getImageSource(comps, stable.Name) if !ok { @@ -67,17 +67,26 @@ func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWi } // ignore current component - if teamInfo.CompName == stable.Name { + isFound := false + for _, qcomp := range teamInfo.Components { + if qcomp.Name == stable.Name { + isFound = true + break + } + } + if isFound { continue } c.detectAndAddImageMissing(*source, stable.Spec.Repository, stable.Name, stable.Spec.Version, imgList) } - // add image missing for current component - source, ok := c.getImageSource(comps, teamInfo.CompName) - if ok { - c.detectAndAddImageMissing(*source, teamInfo.Image.Repository, teamInfo.CompName, teamInfo.Image.Tag, imgList) + // get image missing of current components + for _, qcomp := range teamInfo.Components { + source, ok := c.getImageSource(comps, qcomp.Name) + if ok { + c.detectAndAddImageMissing(*source, qcomp.Image.Repository, qcomp.Name, qcomp.Image.Tag, imgList) + } } return imgList, nil diff --git a/internal/staging/image_missing.go b/internal/staging/image_missing.go index 871550a2..09fca3fa 100644 --- a/internal/staging/image_missing.go +++ b/internal/staging/image_missing.go @@ -13,7 +13,6 @@ import ( "github.com/agoda-com/samsahai/pkg/samsahai/rpc" ) -// TODO: pohfy, detects multiple queues func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { var err error headers := make(http.Header) @@ -24,12 +23,21 @@ func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { return errors.Wrap(err, "cannot set request header") } + rpcComps := make([]*rpc.Component, 0) + for _, qcomp := range queue.Spec.Components { + rpcComps = append(rpcComps, &rpc.Component{ + Name: qcomp.Name, + Image: &rpc.Image{ + Repository: qcomp.Repository, + Tag: qcomp.Version, + }, + }) + } + var imgList *rpc.ImageList - // TODO: pohfy, TeamWithCurrentComponents should contain multiple components comp := &rpc.TeamWithCurrentComponent{ - TeamName: c.teamName, - CompName: queue.Name, - Image: &rpc.Image{Repository: queue.Spec.Repository, Tag: queue.Spec.Version}, + TeamName: c.teamName, + Components: rpcComps, } if c.s2hClient != nil { imgList, err = c.s2hClient.GetMissingVersion(ctx, comp) @@ -39,7 +47,6 @@ func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { } if imgList != nil && imgList.Images != nil && len(imgList.Images) > 0 { - // TODO: pohfy, updateImageMissingWithQueueState receives multiple queues if err := c.updateImageMissingWithQueueState(queue, imgList); err != nil { return err } diff --git a/pkg/samsahai/rpc/service.pb.go b/pkg/samsahai/rpc/service.pb.go index 6925159e..a2f91cf9 100644 --- a/pkg/samsahai/rpc/service.pb.go +++ b/pkg/samsahai/rpc/service.pb.go @@ -554,9 +554,8 @@ type TeamWithCurrentComponent struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TeamName string `protobuf:"bytes,1,opt,name=teamName,proto3" json:"teamName,omitempty"` - CompName string `protobuf:"bytes,2,opt,name=compName,proto3" json:"compName,omitempty"` - Image *Image `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"` + TeamName string `protobuf:"bytes,1,opt,name=teamName,proto3" json:"teamName,omitempty"` + Components []*Component `protobuf:"bytes,2,rep,name=components,proto3" json:"components,omitempty"` } func (x *TeamWithCurrentComponent) Reset() { @@ -598,16 +597,9 @@ func (x *TeamWithCurrentComponent) GetTeamName() string { return "" } -func (x *TeamWithCurrentComponent) GetCompName() string { +func (x *TeamWithCurrentComponent) GetComponents() []*Component { if x != nil { - return x.CompName - } - return "" -} - -func (x *TeamWithCurrentComponent) GetImage() *Image { - if x != nil { - return x.Image + return x.Components } return nil } @@ -695,35 +687,34 @@ var file_pkg_samsahai_rpc_service_proto_rawDesc = []byte{ 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x06, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, - 0x22, 0x85, 0x01, 0x0a, 0x18, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, - 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, - 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, - 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, - 0x65, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x32, 0xae, 0x02, 0x0a, 0x03, 0x52, 0x50, 0x43, - 0x12, 0x5e, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, - 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x26, 0x2e, 0x73, 0x61, - 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, - 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, - 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, - 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x64, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, - 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, 0x61, - 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, - 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, - 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x53, 0x65, 0x6e, 0x64, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, - 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, + 0x22, 0x77, 0x0a, 0x18, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, + 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, + 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x32, 0xae, 0x02, 0x0a, 0x03, 0x52, 0x50, + 0x43, 0x12, 0x5e, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, - 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, 0x63, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, + 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, + 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x12, 0x64, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, + 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, + 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, + 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x53, 0x65, 0x6e, 0x64, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, 0x4d, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, + 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, + 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, + 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -760,7 +751,7 @@ var file_pkg_samsahai_rpc_service_proto_depIdxs = []int32{ 2, // 4: samsahai.io.samsahai.ComponentUpgrade.reverificationStatus:type_name -> samsahai.io.samsahai.ComponentUpgrade.ReverificationStatus 7, // 5: samsahai.io.samsahai.Component.image:type_name -> samsahai.io.samsahai.Image 7, // 6: samsahai.io.samsahai.ImageList.images:type_name -> samsahai.io.samsahai.Image - 7, // 7: samsahai.io.samsahai.TeamWithCurrentComponent.image:type_name -> samsahai.io.samsahai.Image + 6, // 7: samsahai.io.samsahai.TeamWithCurrentComponent.components:type_name -> samsahai.io.samsahai.Component 5, // 8: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:input_type -> samsahai.io.samsahai.ComponentUpgrade 9, // 9: samsahai.io.samsahai.RPC.GetMissingVersion:input_type -> samsahai.io.samsahai.TeamWithCurrentComponent 5, // 10: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:input_type -> samsahai.io.samsahai.ComponentUpgrade diff --git a/pkg/samsahai/rpc/service.proto b/pkg/samsahai/rpc/service.proto index d3045cdd..1af04ddd 100644 --- a/pkg/samsahai/rpc/service.proto +++ b/pkg/samsahai/rpc/service.proto @@ -62,6 +62,5 @@ message ImageList { message TeamWithCurrentComponent { string teamName = 1; - string compName = 2; - Image image = 3; + repeated Component components = 2; } diff --git a/pkg/samsahai/rpc/service.twirp.go b/pkg/samsahai/rpc/service.twirp.go index f699f098..b942e762 100644 --- a/pkg/samsahai/rpc/service.twirp.go +++ b/pkg/samsahai/rpc/service.twirp.go @@ -1209,49 +1209,48 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 699 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x4e, 0x13, 0x41, - 0x14, 0x66, 0x5b, 0x5a, 0xda, 0x83, 0x3f, 0xcb, 0x04, 0xc2, 0x5a, 0x08, 0x34, 0x1b, 0x63, 0x1a, - 0x2f, 0x16, 0x05, 0x6f, 0x8c, 0x17, 0x0a, 0xed, 0x5a, 0x37, 0xd2, 0x05, 0x67, 0x29, 0x24, 0x5e, - 0xd8, 0x8c, 0xdb, 0xb1, 0x4c, 0x74, 0x7f, 0x9c, 0x99, 0x25, 0x69, 0xe2, 0xad, 0x3e, 0x8e, 0xef, - 0xe2, 0x1b, 0x99, 0x1d, 0xda, 0x6e, 0xa1, 0x5b, 0xe9, 0x85, 0x57, 0x7b, 0xe6, 0x9b, 0xf3, 0x3f, - 0xe7, 0x7c, 0x0b, 0x3b, 0xf1, 0xd7, 0xc1, 0x9e, 0x20, 0x81, 0x20, 0x97, 0x84, 0xed, 0xf1, 0xd8, - 0xdf, 0x13, 0x94, 0x5f, 0x31, 0x9f, 0x5a, 0x31, 0x8f, 0x64, 0x84, 0xd6, 0xc7, 0x77, 0x16, 0x8b, - 0xac, 0xb1, 0x6c, 0xae, 0x40, 0xc9, 0x0e, 0x62, 0x39, 0x34, 0x6b, 0xb0, 0x7c, 0x46, 0x49, 0x80, - 0x10, 0x2c, 0x87, 0x24, 0xa0, 0x86, 0x56, 0xd7, 0x1a, 0x55, 0xac, 0x64, 0xf3, 0xcf, 0x0a, 0xe8, - 0xcd, 0x28, 0x88, 0xa3, 0x90, 0x86, 0xb2, 0x1b, 0x0f, 0x38, 0xe9, 0x53, 0x74, 0x0c, 0x65, 0x21, - 0x89, 0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 0xe7, 0x74, 0x76, 0x38, 0x8d, - 0x23, 0xc1, 0xd2, 0x91, 0x1f, 0x79, 0x9d, 0x42, 0x90, 0x0e, 0x45, 0x49, 0x06, 0xa3, 0x65, 0x4f, - 0x45, 0xf3, 0x0d, 0x54, 0x95, 0xa9, 0x1a, 0xeb, 0x03, 0x28, 0x2b, 0x87, 0x29, 0xb5, 0xdc, 0xb9, - 0x15, 0x23, 0x55, 0xf3, 0xa7, 0x06, 0x46, 0xca, 0x60, 0x17, 0x4c, 0x5e, 0x36, 0x13, 0xce, 0x69, - 0x28, 0xb3, 0x02, 0xa7, 0xa9, 0x44, 0xbb, 0x45, 0x25, 0x35, 0xa8, 0xa4, 0xbc, 0xe0, 0x66, 0xf4, - 0x33, 0x39, 0x67, 0x4d, 0x28, 0x2e, 0xda, 0x84, 0xfd, 0xdf, 0x05, 0x28, 0xe2, 0xd3, 0x26, 0xfa, - 0x04, 0x9b, 0x38, 0x09, 0x4f, 0x23, 0x21, 0x67, 0xa8, 0xf3, 0xc9, 0x62, 0xcb, 0x51, 0x9b, 0x13, - 0x4e, 0x11, 0x36, 0xea, 0xc3, 0x5a, 0x9b, 0xca, 0x11, 0x1b, 0x9c, 0x53, 0x2e, 0x58, 0x14, 0x22, - 0x2b, 0xdf, 0x62, 0x5e, 0x5f, 0x6a, 0xbb, 0xff, 0x28, 0x48, 0x3d, 0x05, 0x81, 0x9a, 0x47, 0xc3, - 0x7e, 0x37, 0xee, 0x13, 0xa9, 0x76, 0x89, 0x7e, 0x48, 0xd9, 0xac, 0x43, 0x25, 0x67, 0xfe, 0x7f, - 0x29, 0xe4, 0xa8, 0xf4, 0xb1, 0xc8, 0x63, 0xff, 0x73, 0x59, 0xfd, 0xa6, 0x0e, 0xfe, 0x06, 0x00, - 0x00, 0xff, 0xff, 0x54, 0x04, 0x58, 0x1e, 0xc8, 0x06, 0x00, 0x00, + // 688 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00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xbd, 0x0f, 0x55, 0xe5, 0x30, 0xa3, 0x96, 0x3b, + 0xb7, 0x62, 0xa4, 0x6a, 0x7d, 0x03, 0x33, 0x23, 0xb0, 0x73, 0x26, 0x2f, 0x9a, 0x29, 0xe7, 0x34, + 0x92, 0x79, 0x7d, 0xd3, 0x4c, 0xa2, 0xdd, 0xca, 0x24, 0xa5, 0x3f, 0x66, 0x92, 0xbd, 0x9f, 0x25, + 0x28, 0xe3, 0x93, 0x26, 0xfa, 0x00, 0x1b, 0x38, 0x8d, 0x4e, 0x62, 0x21, 0x67, 0xb8, 0xf2, 0xd1, + 0xfd, 0xb6, 0xa1, 0x36, 0xa7, 0x50, 0xc5, 0xd0, 0xa8, 0x0f, 0xab, 0x6d, 0x2a, 0x47, 0xeb, 0x7f, + 0x46, 0xb9, 0x60, 0x71, 0x84, 0xec, 0x62, 0x8b, 0x79, 0x9d, 0xa8, 0xed, 0xdc, 0xd2, 0x4a, 0xd5, + 0x7b, 0x02, 0x35, 0x9f, 0x46, 0xfd, 0x6e, 0xd2, 0x27, 0x52, 0x2d, 0x0f, 0x7d, 0x97, 0xd1, 0x57, + 0x87, 0x4a, 0xce, 0x82, 0xbf, 0x52, 0xc8, 0x61, 0xe5, 0x7d, 0x99, 0x27, 0xc1, 0xc7, 0xaa, 0xfa, + 0x2f, 0xed, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x51, 0x28, 0x21, 0x20, 0xb9, 0x06, 0x00, 0x00, } From 82eaadbe7445b1fc14baced2e906cb0684ff3c4c Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Wed, 3 Jun 2020 16:34:07 +0700 Subject: [PATCH 05/12] :bento: Implement get bundles from configuration --- api/v1beta1/desiredcomponent_types.go | 2 - api/v1beta1/queue_types.go | 1 - .../env.samsahai.io_desiredcomponents.yaml | 2 - internal/config/controller.go | 19 +- internal/desiredcomponent/controller.go | 11 +- internal/queue/controller.go | 1 - internal/samsahai/internal_process.go | 27 +- internal/samsahai/rpc.go | 23 + internal/staging/collect_result.go | 1 - internal/staging/controller.go | 1 - pkg/samsahai/rpc/service.pb.go | 394 +++++++++++------- pkg/samsahai/rpc/service.proto | 8 +- pkg/samsahai/rpc/service.twirp.go | 275 +++++++++--- 13 files changed, 513 insertions(+), 252 deletions(-) diff --git a/api/v1beta1/desiredcomponent_types.go b/api/v1beta1/desiredcomponent_types.go index eca3375f..9cb0b2d1 100644 --- a/api/v1beta1/desiredcomponent_types.go +++ b/api/v1beta1/desiredcomponent_types.go @@ -25,8 +25,6 @@ type DesiredComponentSpec struct { Name string `json:"name"` Version string `json:"version"` Repository string `json:"repository"` - // +optional - Bundle string `json:"bundle,omitempty"` } // DesiredComponentStatus defines the observed state of DesiredComponent diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 5323967c..ae6cdb1f 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -80,7 +80,6 @@ const ( Finished QueueState = "finished" ) -// TODO: pohfy, name is bundle name // QueueSpec defines the desired state of Queue type QueueSpec struct { // Name represents a Component name or bundle name if exist diff --git a/config/crds/env.samsahai.io_desiredcomponents.yaml b/config/crds/env.samsahai.io_desiredcomponents.yaml index 44ffac44..6cd4f40d 100644 --- a/config/crds/env.samsahai.io_desiredcomponents.yaml +++ b/config/crds/env.samsahai.io_desiredcomponents.yaml @@ -34,8 +34,6 @@ spec: spec: description: DesiredComponentSpec defines the desired state of DesiredComponent properties: - bundle: - type: string name: type: string repository: diff --git a/internal/config/controller.go b/internal/config/controller.go index 35b787a0..a2097d33 100644 --- a/internal/config/controller.go +++ b/internal/config/controller.go @@ -135,20 +135,15 @@ func (c *controller) GetParentComponents(configName string) (map[string]*s2hv1be return filteredComps, nil } -// TODO: pohfy, fix mock -// GetParentComponents returns components that doesn't have parent (nil Parent) +// GetBundles returns all component bundles func (c *controller) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { - //config, err := c.Get(configName) - //if err != nil { - // logger.Error(err, "cannot get Config", "name", configName) - // return s2hv1beta1.ConfigBundles{}, err - //} - - //config.Spec. + config, err := c.Get(configName) + if err != nil { + logger.Error(err, "cannot get Config", "name", configName) + return s2hv1beta1.ConfigBundles{}, err + } - return s2hv1beta1.ConfigBundles{ - "db": []string{"mariadb", "redis"}, - }, nil + return config.Spec.Bundles, nil } // Update updates Config CRD diff --git a/internal/desiredcomponent/controller.go b/internal/desiredcomponent/controller.go index f9c97b85..e92cada4 100644 --- a/internal/desiredcomponent/controller.go +++ b/internal/desiredcomponent/controller.go @@ -119,7 +119,14 @@ func (c *controller) Reconcile(req reconcile.Request) (reconcile.Result, error) logger.Error(err, "cannot set request header") } - // TODO: pohfy, get bundle config + bundle, err := c.s2hClient.GetBundleName(ctx, &samsahairpc.TeamWithComponentName{ + TeamName: c.teamName, + ComponentName: comp.Spec.Name, + }) + if err != nil { + logger.Error(err, "cannot get bundle name", "team", c.teamName, "component", comp.Spec.Name) + } + comps := []*s2hv1beta1.QueueComponent{ { Name: comp.Spec.Name, @@ -127,7 +134,7 @@ func (c *controller) Reconcile(req reconcile.Request) (reconcile.Result, error) Version: comp.Spec.Version, }, } - q := queue.NewUpgradeQueue(c.teamName, req.Namespace, comp.Spec.Name, comp.Spec.Bundle, comps) + q := queue.NewUpgradeQueue(c.teamName, req.Namespace, comp.Spec.Name, bundle.Name, comps) err = c.queueCtrl.Add(q) if err != nil { return reconcile.Result{}, err diff --git a/internal/queue/controller.go b/internal/queue/controller.go index 091ba8e5..bb5d43d3 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -106,7 +106,6 @@ func (c *controller) RemoveAllQueues() error { return c.client.DeleteAllOf(context.TODO(), &s2hv1beta1.Queue{}, client.InNamespace(c.namespace)) } -// TODO: pohfy, check bundle and add to group instead func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop bool) error { queueList, err := c.list(nil) if err != nil { diff --git a/internal/samsahai/internal_process.go b/internal/samsahai/internal_process.go index e224f71f..dc897586 100644 --- a/internal/samsahai/internal_process.go +++ b/internal/samsahai/internal_process.go @@ -20,7 +20,6 @@ import ( const maxDesiredMappingPerComp = 10 -// TODO: pohfy, add bundle here type changedComponent struct { Name string Repository string @@ -38,8 +37,6 @@ type updateTeamDesiredComponent struct { ComponentName string ComponentSource string ComponentImage s2hv1beta1.ComponentImage - // TODO: pohfy, add bundle here - ComponentBundle string } func (c *controller) Start(stop <-chan struct{}) { @@ -108,6 +105,7 @@ func (c *controller) process() bool { return true } +// TODO: pohfy, check bundle changed // checkComponentChanged checks matched components from every teams and add to queue for checking new version. // // Component should match both name and repository @@ -145,15 +143,12 @@ func (c *controller) checkComponentChanged(component changedComponent) error { logger.Debug("component has been notified", "team", teamName, "component", comp.Name) - // TODO: pohfy, add component bundle here // add to queue for processing - bundleName := getBundleName(comp.Name, teamName, configCtrl) c.queue.Add(updateTeamDesiredComponent{ TeamName: teamName, ComponentName: comp.Name, ComponentSource: string(*comp.Source), ComponentImage: comp.Image, - ComponentBundle: bundleName, }) } } @@ -182,7 +177,6 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp compNs := team.Status.Namespace.Staging compName := updateInfo.ComponentName compRepository := updateInfo.ComponentImage.Repository - compBundle := updateInfo.ComponentBundle // TODO: do caching for better performance version, vErr := checker.GetVersion(compRepository, compName, checkPattern) @@ -233,7 +227,6 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp Version: version, Name: compName, Repository: compRepository, - Bundle: compBundle, }, Status: s2hv1beta1.DesiredComponentStatus{ CreatedAt: &now, @@ -253,17 +246,14 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp return err } - // TODO: pohfy, added bundle // DesiredComponent found, check the version - if desiredComp.Spec.Version == version && desiredComp.Spec.Repository == compRepository && - desiredComp.Spec.Bundle == compBundle { + if desiredComp.Spec.Version == version && desiredComp.Spec.Repository == compRepository { return nil } // Update when version or repository changed desiredComp.Spec.Version = version desiredComp.Spec.Repository = compRepository - desiredComp.Spec.Bundle = compBundle desiredComp.Status.UpdatedAt = &now if err = c.client.Update(ctx, desiredComp); err != nil { @@ -293,19 +283,6 @@ type desiredTime struct { desiredImageTime s2hv1beta1.DesiredImageTime } -func getBundleName(compName, teamName string, configCtrl internal.ConfigController) string { - bundles, _ := configCtrl.GetBundles(teamName) - for bundleName, comps := range bundles { - for _, comp := range comps { - if comp == compName { - return bundleName - } - } - } - - return "" -} - func deleteDesiredMappingOutOfRange(team *s2hv1beta1.Team, maxDesiredMapping int) { desiredMap := team.Status.DesiredComponentImageCreatedTime for compName, m := range desiredMap { diff --git a/internal/samsahai/rpc.go b/internal/samsahai/rpc.go index 72ad47cb..d78800f2 100644 --- a/internal/samsahai/rpc.go +++ b/internal/samsahai/rpc.go @@ -232,3 +232,26 @@ func (c *controller) SendUpdateStateQueueMetric(ctx context.Context, comp *rpc.C return &rpc.Empty{}, nil } + +func (c *controller) GetBundleName(ctx context.Context, teamWithCompName *rpc.TeamWithComponentName) (*rpc.BundleName, error) { + if err := c.authenticateRPC(ctx); err != nil { + return nil, err + } + + bundleName := c.getBundleName(teamWithCompName.ComponentName, teamWithCompName.TeamName) + + return &rpc.BundleName{Name: bundleName}, nil +} + +func (c *controller) getBundleName(compName, teamName string) string { + bundles, _ := c.GetConfigController().GetBundles(teamName) + for bundleName, comps := range bundles { + for _, comp := range comps { + if comp == compName { + return bundleName + } + } + } + + return "" +} diff --git a/internal/staging/collect_result.go b/internal/staging/collect_result.go index 695a81d0..6fad0039 100644 --- a/internal/staging/collect_result.go +++ b/internal/staging/collect_result.go @@ -404,7 +404,6 @@ func (c *controller) sendComponentUpgradeReport(status rpc.ComponentUpgrade_Upgr }) } - // TODO: pohfy, update report here comp := &rpc.ComponentUpgrade{ Status: status, Name: queue.Spec.Name, diff --git a/internal/staging/controller.go b/internal/staging/controller.go index 4a121e53..438ca05e 100644 --- a/internal/staging/controller.go +++ b/internal/staging/controller.go @@ -159,7 +159,6 @@ func (c *controller) process() bool { } } - // TODO: pohfy, pick queues with same bundle queue := c.getCurrentQueue() switch queue.Spec.Type { diff --git a/pkg/samsahai/rpc/service.pb.go b/pkg/samsahai/rpc/service.pb.go index a2f91cf9..2fff8a56 100644 --- a/pkg/samsahai/rpc/service.pb.go +++ b/pkg/samsahai/rpc/service.pb.go @@ -68,7 +68,7 @@ func (x ComponentUpgrade_UpgradeStatus) Number() protoreflect.EnumNumber { // Deprecated: Use ComponentUpgrade_UpgradeStatus.Descriptor instead. func (ComponentUpgrade_UpgradeStatus) EnumDescriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 0} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3, 0} } type ComponentUpgrade_IssueType int32 @@ -120,7 +120,7 @@ func (x ComponentUpgrade_IssueType) Number() protoreflect.EnumNumber { // Deprecated: Use ComponentUpgrade_IssueType.Descriptor instead. func (ComponentUpgrade_IssueType) EnumDescriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 1} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3, 1} } type ComponentUpgrade_ReverificationStatus int32 @@ -169,7 +169,7 @@ func (x ComponentUpgrade_ReverificationStatus) Number() protoreflect.EnumNumber // Deprecated: Use ComponentUpgrade_ReverificationStatus.Descriptor instead. func (ComponentUpgrade_ReverificationStatus) EnumDescriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2, 2} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3, 2} } type Empty struct { @@ -210,16 +210,17 @@ func (*Empty) Descriptor() ([]byte, []int) { return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{0} } -type Team struct { +type TeamWithComponentName struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + TeamName string `protobuf:"bytes,1,opt,name=teamName,proto3" json:"teamName,omitempty"` + ComponentName string `protobuf:"bytes,2,opt,name=componentName,proto3" json:"componentName,omitempty"` } -func (x *Team) Reset() { - *x = Team{} +func (x *TeamWithComponentName) Reset() { + *x = TeamWithComponentName{} if protoimpl.UnsafeEnabled { mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -227,13 +228,13 @@ func (x *Team) Reset() { } } -func (x *Team) String() string { +func (x *TeamWithComponentName) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Team) ProtoMessage() {} +func (*TeamWithComponentName) ProtoMessage() {} -func (x *Team) ProtoReflect() protoreflect.Message { +func (x *TeamWithComponentName) ProtoReflect() protoreflect.Message { mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -245,12 +246,66 @@ func (x *Team) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Team.ProtoReflect.Descriptor instead. -func (*Team) Descriptor() ([]byte, []int) { +// Deprecated: Use TeamWithComponentName.ProtoReflect.Descriptor instead. +func (*TeamWithComponentName) Descriptor() ([]byte, []int) { return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{1} } -func (x *Team) GetName() string { +func (x *TeamWithComponentName) GetTeamName() string { + if x != nil { + return x.TeamName + } + return "" +} + +func (x *TeamWithComponentName) GetComponentName() string { + if x != nil { + return x.ComponentName + } + return "" +} + +type BundleName struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *BundleName) Reset() { + *x = BundleName{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BundleName) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BundleName) ProtoMessage() {} + +func (x *BundleName) ProtoReflect() protoreflect.Message { + mi := &file_pkg_samsahai_rpc_service_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 BundleName.ProtoReflect.Descriptor instead. +func (*BundleName) Descriptor() ([]byte, []int) { + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2} +} + +func (x *BundleName) GetName() string { if x != nil { return x.Name } @@ -279,7 +334,7 @@ type ComponentUpgrade struct { func (x *ComponentUpgrade) Reset() { *x = ComponentUpgrade{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[2] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -292,7 +347,7 @@ func (x *ComponentUpgrade) String() string { func (*ComponentUpgrade) ProtoMessage() {} func (x *ComponentUpgrade) ProtoReflect() protoreflect.Message { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[2] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -305,7 +360,7 @@ func (x *ComponentUpgrade) ProtoReflect() protoreflect.Message { // Deprecated: Use ComponentUpgrade.ProtoReflect.Descriptor instead. func (*ComponentUpgrade) Descriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{2} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3} } func (x *ComponentUpgrade) GetStatus() ComponentUpgrade_UpgradeStatus { @@ -404,7 +459,7 @@ type Component struct { func (x *Component) Reset() { *x = Component{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[3] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -417,7 +472,7 @@ func (x *Component) String() string { func (*Component) ProtoMessage() {} func (x *Component) ProtoReflect() protoreflect.Message { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[3] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -430,7 +485,7 @@ func (x *Component) ProtoReflect() protoreflect.Message { // Deprecated: Use Component.ProtoReflect.Descriptor instead. func (*Component) Descriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{3} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{4} } func (x *Component) GetName() string { @@ -459,7 +514,7 @@ type Image struct { func (x *Image) Reset() { *x = Image{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[4] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -472,7 +527,7 @@ func (x *Image) String() string { func (*Image) ProtoMessage() {} func (x *Image) ProtoReflect() protoreflect.Message { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[4] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -485,7 +540,7 @@ func (x *Image) ProtoReflect() protoreflect.Message { // Deprecated: Use Image.ProtoReflect.Descriptor instead. func (*Image) Descriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{4} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{5} } func (x *Image) GetRepository() string { @@ -513,7 +568,7 @@ type ImageList struct { func (x *ImageList) Reset() { *x = ImageList{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[5] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -526,7 +581,7 @@ func (x *ImageList) String() string { func (*ImageList) ProtoMessage() {} func (x *ImageList) ProtoReflect() protoreflect.Message { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[5] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -539,7 +594,7 @@ func (x *ImageList) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageList.ProtoReflect.Descriptor instead. func (*ImageList) Descriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{5} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{6} } func (x *ImageList) GetImages() []*Image { @@ -561,7 +616,7 @@ type TeamWithCurrentComponent struct { func (x *TeamWithCurrentComponent) Reset() { *x = TeamWithCurrentComponent{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[6] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -574,7 +629,7 @@ func (x *TeamWithCurrentComponent) String() string { func (*TeamWithCurrentComponent) ProtoMessage() {} func (x *TeamWithCurrentComponent) ProtoReflect() protoreflect.Message { - mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[6] + mi := &file_pkg_samsahai_rpc_service_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -587,7 +642,7 @@ func (x *TeamWithCurrentComponent) ProtoReflect() protoreflect.Message { // Deprecated: Use TeamWithCurrentComponent.ProtoReflect.Descriptor instead. func (*TeamWithCurrentComponent) Descriptor() ([]byte, []int) { - return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{6} + return file_pkg_samsahai_rpc_service_proto_rawDescGZIP(), []int{7} } func (x *TeamWithCurrentComponent) GetTeamName() string { @@ -611,110 +666,122 @@ var file_pkg_samsahai_rpc_service_proto_rawDesc = []byte{ 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x1a, 0x0a, 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xd1, 0x07, 0x0a, 0x10, - 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, - 0x12, 0x4c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x34, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, - 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3f, - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, - 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, - 0x4e, 0x0a, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, - 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x2a, 0x0a, 0x10, 0x71, 0x75, 0x65, 0x75, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4e, - 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x71, 0x75, 0x65, 0x75, 0x65, - 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x10, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x18, - 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, - 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, - 0x67, 0x65, 0x52, 0x10, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, - 0x79, 0x70, 0x65, 0x49, 0x44, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, 0x73, - 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, - 0x72, 0x75, 0x6e, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x75, 0x6e, 0x73, - 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, - 0x12, 0x6f, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, - 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, - 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, - 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x14, 0x72, 0x65, 0x76, - 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x45, 0x0a, 0x0d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x00, 0x12, 0x19, 0x0a, - 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x53, - 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x22, 0x86, 0x01, 0x0a, 0x09, 0x49, 0x73, 0x73, - 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x24, 0x0a, - 0x20, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x44, 0x45, 0x53, 0x49, 0x52, - 0x45, 0x44, 0x5f, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, - 0x44, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x02, - 0x12, 0x1f, 0x0a, 0x1b, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x45, 0x4e, - 0x56, 0x49, 0x52, 0x4f, 0x4e, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, - 0x03, 0x22, 0x7c, 0x0a, 0x14, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x1c, 0x52, 0x65, 0x76, - 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x52, - 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x01, 0x12, 0x20, 0x0a, - 0x1c, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, 0x22, - 0x52, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x31, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, - 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x05, 0x69, 0x6d, - 0x61, 0x67, 0x65, 0x22, 0x39, 0x0a, 0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, - 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x40, - 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x06, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, - 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, - 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x06, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, - 0x22, 0x77, 0x0a, 0x18, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, - 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, - 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, - 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, - 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x32, 0xae, 0x02, 0x0a, 0x03, 0x52, 0x50, - 0x43, 0x12, 0x5e, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x26, 0x2e, 0x73, - 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, - 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, - 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x12, 0x64, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, - 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, - 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, + 0x59, 0x0a, 0x15, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x61, 0x6d, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x61, 0x6d, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x20, 0x0a, 0x0a, 0x42, 0x75, + 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xd1, 0x07, 0x0a, + 0x10, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x12, 0x4c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x34, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, + 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x3f, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, + 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x4e, 0x0a, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, + 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x49, 0x73, 0x73, 0x75, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x69, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x2a, 0x0a, 0x10, 0x71, 0x75, 0x65, 0x75, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x71, 0x75, 0x65, 0x75, + 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x10, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, + 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, - 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x53, 0x65, 0x6e, 0x64, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, - 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, + 0x61, 0x67, 0x65, 0x52, 0x10, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, + 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x54, 0x79, 0x70, 0x65, 0x49, 0x44, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, + 0x73, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x49, 0x44, 0x12, 0x12, 0x0a, + 0x04, 0x72, 0x75, 0x6e, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x75, 0x6e, + 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, + 0x79, 0x12, 0x6f, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x3b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, + 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x14, 0x72, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x22, 0x45, 0x0a, 0x0d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x00, 0x12, 0x19, + 0x0a, 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, + 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x22, 0x86, 0x01, 0x0a, 0x09, 0x49, 0x73, + 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x73, 0x73, 0x75, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x24, + 0x0a, 0x20, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x44, 0x45, 0x53, 0x49, + 0x52, 0x45, 0x44, 0x5f, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x46, 0x41, 0x49, 0x4c, + 0x45, 0x44, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, + 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x45, + 0x4e, 0x56, 0x49, 0x52, 0x4f, 0x4e, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, + 0x10, 0x03, 0x22, 0x7c, 0x0a, 0x14, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x1c, 0x52, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, + 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x01, 0x12, 0x20, + 0x0a, 0x1c, 0x52, 0x65, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, + 0x22, 0x52, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x31, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x05, 0x69, + 0x6d, 0x61, 0x67, 0x65, 0x22, 0x39, 0x0a, 0x05, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, + 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, + 0x40, 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x06, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, + 0x68, 0x61, 0x69, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x06, 0x69, 0x6d, 0x61, 0x67, 0x65, + 0x73, 0x22, 0x77, 0x0a, 0x18, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x74, 0x65, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, - 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, - 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x52, 0x0a, + 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x32, 0x8e, 0x03, 0x0a, 0x03, 0x52, + 0x50, 0x43, 0x12, 0x5e, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x12, 0x26, 0x2e, + 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, + 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, + 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x12, 0x64, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, + 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x54, + 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, + 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, + 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x53, 0x65, 0x6e, 0x64, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, + 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x26, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, + 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x43, 0x6f, + 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x1b, + 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, + 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x5e, 0x0a, 0x0d, 0x47, + 0x65, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x2e, 0x73, + 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, + 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x1a, 0x20, 0x2e, 0x73, 0x61, 0x6d, 0x73, + 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, + 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x05, 0x5a, 0x03, 0x72, + 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -730,36 +797,39 @@ func file_pkg_samsahai_rpc_service_proto_rawDescGZIP() []byte { } var file_pkg_samsahai_rpc_service_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_pkg_samsahai_rpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_pkg_samsahai_rpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_pkg_samsahai_rpc_service_proto_goTypes = []interface{}{ (ComponentUpgrade_UpgradeStatus)(0), // 0: samsahai.io.samsahai.ComponentUpgrade.UpgradeStatus (ComponentUpgrade_IssueType)(0), // 1: samsahai.io.samsahai.ComponentUpgrade.IssueType (ComponentUpgrade_ReverificationStatus)(0), // 2: samsahai.io.samsahai.ComponentUpgrade.ReverificationStatus (*Empty)(nil), // 3: samsahai.io.samsahai.Empty - (*Team)(nil), // 4: samsahai.io.samsahai.Team - (*ComponentUpgrade)(nil), // 5: samsahai.io.samsahai.ComponentUpgrade - (*Component)(nil), // 6: samsahai.io.samsahai.Component - (*Image)(nil), // 7: samsahai.io.samsahai.Image - (*ImageList)(nil), // 8: samsahai.io.samsahai.ImageList - (*TeamWithCurrentComponent)(nil), // 9: samsahai.io.samsahai.TeamWithCurrentComponent + (*TeamWithComponentName)(nil), // 4: samsahai.io.samsahai.TeamWithComponentName + (*BundleName)(nil), // 5: samsahai.io.samsahai.BundleName + (*ComponentUpgrade)(nil), // 6: samsahai.io.samsahai.ComponentUpgrade + (*Component)(nil), // 7: samsahai.io.samsahai.Component + (*Image)(nil), // 8: samsahai.io.samsahai.Image + (*ImageList)(nil), // 9: samsahai.io.samsahai.ImageList + (*TeamWithCurrentComponent)(nil), // 10: samsahai.io.samsahai.TeamWithCurrentComponent } var file_pkg_samsahai_rpc_service_proto_depIdxs = []int32{ 0, // 0: samsahai.io.samsahai.ComponentUpgrade.status:type_name -> samsahai.io.samsahai.ComponentUpgrade.UpgradeStatus - 6, // 1: samsahai.io.samsahai.ComponentUpgrade.components:type_name -> samsahai.io.samsahai.Component + 7, // 1: samsahai.io.samsahai.ComponentUpgrade.components:type_name -> samsahai.io.samsahai.Component 1, // 2: samsahai.io.samsahai.ComponentUpgrade.issueType:type_name -> samsahai.io.samsahai.ComponentUpgrade.IssueType - 7, // 3: samsahai.io.samsahai.ComponentUpgrade.imageMissingList:type_name -> samsahai.io.samsahai.Image + 8, // 3: samsahai.io.samsahai.ComponentUpgrade.imageMissingList:type_name -> samsahai.io.samsahai.Image 2, // 4: samsahai.io.samsahai.ComponentUpgrade.reverificationStatus:type_name -> samsahai.io.samsahai.ComponentUpgrade.ReverificationStatus - 7, // 5: samsahai.io.samsahai.Component.image:type_name -> samsahai.io.samsahai.Image - 7, // 6: samsahai.io.samsahai.ImageList.images:type_name -> samsahai.io.samsahai.Image - 6, // 7: samsahai.io.samsahai.TeamWithCurrentComponent.components:type_name -> samsahai.io.samsahai.Component - 5, // 8: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:input_type -> samsahai.io.samsahai.ComponentUpgrade - 9, // 9: samsahai.io.samsahai.RPC.GetMissingVersion:input_type -> samsahai.io.samsahai.TeamWithCurrentComponent - 5, // 10: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:input_type -> samsahai.io.samsahai.ComponentUpgrade - 3, // 11: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:output_type -> samsahai.io.samsahai.Empty - 8, // 12: samsahai.io.samsahai.RPC.GetMissingVersion:output_type -> samsahai.io.samsahai.ImageList - 3, // 13: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:output_type -> samsahai.io.samsahai.Empty - 11, // [11:14] is the sub-list for method output_type - 8, // [8:11] is the sub-list for method input_type + 8, // 5: samsahai.io.samsahai.Component.image:type_name -> samsahai.io.samsahai.Image + 8, // 6: samsahai.io.samsahai.ImageList.images:type_name -> samsahai.io.samsahai.Image + 7, // 7: samsahai.io.samsahai.TeamWithCurrentComponent.components:type_name -> samsahai.io.samsahai.Component + 6, // 8: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:input_type -> samsahai.io.samsahai.ComponentUpgrade + 10, // 9: samsahai.io.samsahai.RPC.GetMissingVersion:input_type -> samsahai.io.samsahai.TeamWithCurrentComponent + 6, // 10: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:input_type -> samsahai.io.samsahai.ComponentUpgrade + 4, // 11: samsahai.io.samsahai.RPC.GetBundleName:input_type -> samsahai.io.samsahai.TeamWithComponentName + 3, // 12: samsahai.io.samsahai.RPC.RunPostComponentUpgrade:output_type -> samsahai.io.samsahai.Empty + 9, // 13: samsahai.io.samsahai.RPC.GetMissingVersion:output_type -> samsahai.io.samsahai.ImageList + 3, // 14: samsahai.io.samsahai.RPC.SendUpdateStateQueueMetric:output_type -> samsahai.io.samsahai.Empty + 5, // 15: samsahai.io.samsahai.RPC.GetBundleName:output_type -> samsahai.io.samsahai.BundleName + 12, // [12:16] is the sub-list for method output_type + 8, // [8:12] 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 @@ -784,7 +854,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Team); i { + switch v := v.(*TeamWithComponentName); i { case 0: return &v.state case 1: @@ -796,7 +866,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ComponentUpgrade); i { + switch v := v.(*BundleName); i { case 0: return &v.state case 1: @@ -808,7 +878,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Component); i { + switch v := v.(*ComponentUpgrade); i { case 0: return &v.state case 1: @@ -820,7 +890,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Image); i { + switch v := v.(*Component); i { case 0: return &v.state case 1: @@ -832,7 +902,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ImageList); i { + switch v := v.(*Image); i { case 0: return &v.state case 1: @@ -844,6 +914,18 @@ func file_pkg_samsahai_rpc_service_proto_init() { } } file_pkg_samsahai_rpc_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ImageList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_samsahai_rpc_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TeamWithCurrentComponent); i { case 0: return &v.state @@ -862,7 +944,7 @@ func file_pkg_samsahai_rpc_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pkg_samsahai_rpc_service_proto_rawDesc, NumEnums: 3, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/samsahai/rpc/service.proto b/pkg/samsahai/rpc/service.proto index 1af04ddd..a4c661e9 100644 --- a/pkg/samsahai/rpc/service.proto +++ b/pkg/samsahai/rpc/service.proto @@ -7,12 +7,18 @@ service RPC { rpc RunPostComponentUpgrade (ComponentUpgrade) returns (Empty); rpc GetMissingVersion (TeamWithCurrentComponent) returns (ImageList); rpc SendUpdateStateQueueMetric (ComponentUpgrade) returns (Empty); + rpc GetBundleName (TeamWithComponentName) returns (BundleName); } message Empty { } -message Team { +message TeamWithComponentName { + string teamName = 1; + string componentName = 2; +} + +message BundleName { string name = 1; } diff --git a/pkg/samsahai/rpc/service.twirp.go b/pkg/samsahai/rpc/service.twirp.go index b942e762..7b3ba2e5 100644 --- a/pkg/samsahai/rpc/service.twirp.go +++ b/pkg/samsahai/rpc/service.twirp.go @@ -38,6 +38,8 @@ type RPC interface { GetMissingVersion(context.Context, *TeamWithCurrentComponent) (*ImageList, error) SendUpdateStateQueueMetric(context.Context, *ComponentUpgrade) (*Empty, error) + + GetBundleName(context.Context, *TeamWithComponentName) (*BundleName, error) } // =================== @@ -46,7 +48,7 @@ type RPC interface { type rPCProtobufClient struct { client HTTPClient - urls [3]string + urls [4]string opts twirp.ClientOptions } @@ -63,10 +65,11 @@ func NewRPCProtobufClient(addr string, client HTTPClient, opts ...twirp.ClientOp } prefix := urlBase(addr) + RPCPathPrefix - urls := [3]string{ + urls := [4]string{ prefix + "RunPostComponentUpgrade", prefix + "GetMissingVersion", prefix + "SendUpdateStateQueueMetric", + prefix + "GetBundleName", } return &rPCProtobufClient{ @@ -136,13 +139,33 @@ func (c *rPCProtobufClient) SendUpdateStateQueueMetric(ctx context.Context, in * return out, nil } +func (c *rPCProtobufClient) GetBundleName(ctx context.Context, in *TeamWithComponentName) (*BundleName, error) { + ctx = ctxsetters.WithPackageName(ctx, "samsahai.io.samsahai") + ctx = ctxsetters.WithServiceName(ctx, "RPC") + ctx = ctxsetters.WithMethodName(ctx, "GetBundleName") + out := new(BundleName) + err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + // =============== // RPC JSON Client // =============== type rPCJSONClient struct { client HTTPClient - urls [3]string + urls [4]string opts twirp.ClientOptions } @@ -159,10 +182,11 @@ func NewRPCJSONClient(addr string, client HTTPClient, opts ...twirp.ClientOption } prefix := urlBase(addr) + RPCPathPrefix - urls := [3]string{ + urls := [4]string{ prefix + "RunPostComponentUpgrade", prefix + "GetMissingVersion", prefix + "SendUpdateStateQueueMetric", + prefix + "GetBundleName", } return &rPCJSONClient{ @@ -232,6 +256,26 @@ func (c *rPCJSONClient) SendUpdateStateQueueMetric(ctx context.Context, in *Comp return out, nil } +func (c *rPCJSONClient) GetBundleName(ctx context.Context, in *TeamWithComponentName) (*BundleName, error) { + ctx = ctxsetters.WithPackageName(ctx, "samsahai.io.samsahai") + ctx = ctxsetters.WithServiceName(ctx, "RPC") + ctx = ctxsetters.WithMethodName(ctx, "GetBundleName") + out := new(BundleName) + err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + // ================== // RPC Server Handler // ================== @@ -289,6 +333,9 @@ func (s *rPCServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { case "/twirp/samsahai.io.samsahai.RPC/SendUpdateStateQueueMetric": s.serveSendUpdateStateQueueMetric(ctx, resp, req) return + case "/twirp/samsahai.io.samsahai.RPC/GetBundleName": + s.serveGetBundleName(ctx, resp, req) + return default: msg := fmt.Sprintf("no handler for path %q", req.URL.Path) err = badRouteError(msg, req.Method, req.URL.Path) @@ -684,6 +731,135 @@ func (s *rPCServer) serveSendUpdateStateQueueMetricProtobuf(ctx context.Context, callResponseSent(ctx, s.hooks) } +func (s *rPCServer) serveGetBundleName(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveGetBundleNameJSON(ctx, resp, req) + case "application/protobuf": + s.serveGetBundleNameProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *rPCServer) serveGetBundleNameJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "GetBundleName") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(TeamWithComponentName) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + // Call service method + var respContent *BundleName + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = s.RPC.GetBundleName(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *BundleName and nil error while calling GetBundleName. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *rPCServer) serveGetBundleNameProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "GetBundleName") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(TeamWithComponentName) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + // Call service method + var respContent *BundleName + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = s.RPC.GetBundleName(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *BundleName and nil error while calling GetBundleName. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + func (s *rPCServer) ServiceDescriptor() ([]byte, int) { return twirpFileDescriptor0, 0 } @@ -1209,48 +1385,51 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 688 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x4e, 0x13, 0x4f, - 0x14, 0x67, 0x5b, 0x5a, 0xd8, 0xc3, 0xff, 0x63, 0x99, 0x40, 0x58, 0x0b, 0x81, 0x66, 0x63, 0x4c, - 0xe3, 0xc5, 0xa2, 0xe0, 0x8d, 0xf1, 0x42, 0xa1, 0x5d, 0xeb, 0x46, 0xba, 0xe0, 0x2c, 0x85, 0xc4, - 0x0b, 0x9b, 0x71, 0x3b, 0x96, 0x89, 0xee, 0x87, 0x33, 0xb3, 0x98, 0x26, 0x5e, 0xfb, 0x38, 0xbe, - 0x8b, 0x6f, 0x64, 0x76, 0x68, 0xbb, 0x85, 0x6e, 0x01, 0x13, 0xaf, 0xf6, 0xcc, 0x6f, 0xce, 0xf7, - 0x9c, 0xf3, 0x5b, 0xd8, 0x4e, 0x3e, 0x0f, 0x76, 0x05, 0x09, 0x05, 0xb9, 0x20, 0x6c, 0x97, 0x27, - 0xc1, 0xae, 0xa0, 0xfc, 0x92, 0x05, 0xd4, 0x4e, 0x78, 0x2c, 0x63, 0xb4, 0x36, 0xbe, 0xb3, 0x59, - 0x6c, 0x8f, 0x65, 0x6b, 0x09, 0x2a, 0x4e, 0x98, 0xc8, 0xa1, 0x55, 0x83, 0xc5, 0x53, 0x4a, 0x42, - 0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 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x51, 0x28, 0x21, 0x20, 0xb9, 0x06, 0x00, 0x00, + // 732 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5f, 0x4f, 0xd3, 0x50, + 0x14, 0xa7, 0x1b, 0x1b, 0xec, 0x20, 0x5a, 0x6e, 0x20, 0xd4, 0x41, 0xa0, 0x69, 0x88, 0x59, 0x34, + 0x19, 0x0a, 0xbe, 0x18, 0x1f, 0x14, 0xb6, 0x3a, 0x1b, 0x59, 0xc1, 0x5b, 0x06, 0xd1, 0x07, 0x96, + 0xba, 0x5d, 0xc7, 0x8d, 0xac, 0xad, 0xf7, 0xde, 0x62, 0x96, 0xf8, 0xec, 0xa3, 0xdf, 0xcd, 0x6f, + 0x64, 0x7a, 0xd9, 0xda, 0x8e, 0x75, 0x0c, 0x13, 0x9f, 0x7a, 0x7a, 0xee, 0xef, 0xfc, 0xf9, 0x9d, + 0x7b, 0xce, 0xb9, 0xb0, 0x15, 0x7c, 0xeb, 0xed, 0x72, 0xb7, 0xcf, 0xdd, 0x4b, 0x97, 0xee, 0xb2, + 0xa0, 0xb3, 0xcb, 0x09, 0xbb, 0xa6, 0x1d, 0x52, 0x0d, 0x98, 0x2f, 0x7c, 0xb4, 0x3a, 0x3a, 0xab, + 0x52, 0xbf, 0x3a, 0x92, 0x8d, 0x05, 0x28, 0x98, 0xfd, 0x40, 0x0c, 0x8c, 0x4f, 0xb0, 0x76, 0x4a, + 0xdc, 0xfe, 0x39, 0x15, 0x97, 0x35, 0xbf, 0x1f, 0xf8, 0x1e, 0xf1, 0x84, 0xed, 0xf6, 0x09, 0x2a, + 0xc3, 0xa2, 0x20, 0x6e, 0x3f, 0x92, 0x35, 0x45, 0x57, 0x2a, 0x25, 0x1c, 0xff, 0xa3, 0x1d, 0x58, + 0xee, 0xa4, 0xc1, 0x5a, 0x4e, 0x02, 0xc6, 0x95, 0x86, 0x0e, 0x70, 0x18, 0x7a, 0xdd, 0x2b, 0x22, + 0x6d, 0x10, 0xcc, 0x7b, 0x89, 0x2f, 0x29, 0x1b, 0x7f, 0x16, 0x40, 0x8d, 0xa3, 0xb6, 0x82, 0x1e, + 0x73, 0xbb, 0x04, 0x1d, 0x41, 0x91, 0x0b, 0x57, 0x84, 0x5c, 0x42, 0x1f, 0xee, 0xbd, 0xac, 0x66, + 0x31, 0xa8, 0xde, 0xb6, 0xab, 0x0e, 0xbf, 0x8e, 0xb4, 0xc5, 0x43, 0x1f, 0x71, 0xd8, 0x5c, 0x12, + 0x76, 0x8c, 0x5a, 0xfe, 0x16, 0xb5, 0x37, 0x00, 0x31, 0x0b, 0xae, 0xcd, 0xeb, 0xf9, 0xca, 0xd2, + 0xde, 0xf6, 0x8c, 0x0c, 0x70, 0xca, 0x04, 0xd9, 0x50, 0xa2, 0x9c, 0x87, 0xe4, 0x74, 0x10, 0x10, + 0xad, 0x20, 0x19, 0x3c, 0xbf, 0x27, 0x03, 0x6b, 0x64, 0x87, 0x13, 0x17, 0xe8, 0x29, 0xa8, 0xdf, + 0x43, 0x12, 0x92, 0xf7, 0x94, 0x0b, 0x9f, 0x0d, 0x64, 0xd2, 0x45, 0x99, 0xf4, 0x84, 0x1e, 0x35, + 0x40, 0xa5, 0x7d, 0xb7, 0x47, 0x9a, 0x94, 0x73, 0xea, 0xf5, 0x8e, 0x28, 0x17, 0xda, 0x82, 0xa4, + 0xb0, 0x91, 0x9d, 0x82, 0x15, 0xa1, 0xf1, 0x84, 0x11, 0xda, 0x84, 0x52, 0x54, 0x29, 0x1e, 0xb8, + 0x1d, 0xa2, 0x2d, 0xca, 0x68, 0x89, 0x02, 0x55, 0xe0, 0x91, 0x20, 0x5c, 0x1c, 0x86, 0xf4, 0xaa, + 0x1b, 0xe5, 0x68, 0xd5, 0xb5, 0x92, 0xc4, 0xdc, 0x56, 0x47, 0xd5, 0x67, 0xa1, 0xc7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x82, 0xce, 0x97, 0xa2, 0x7c, 0x58, 0xf7, 0xff, 0x06, + 0x00, 0x00, 0xff, 0xff, 0x4e, 0xd9, 0x30, 0xf6, 0x7a, 0x07, 0x00, 0x00, } From 22f51e142402f486e4e87fdaa9a7e50722f73bc2 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Wed, 3 Jun 2020 19:41:34 +0700 Subject: [PATCH 06/12] :construction: Update queue if components have been removed --- api/v1beta1/desiredcomponent_types.go | 7 +- api/v1beta1/queue_types.go | 21 +- .../env.samsahai.io_desiredcomponents.yaml | 2 + .../crds/env.samsahai.io_queuehistories.yaml | 5 +- config/crds/env.samsahai.io_queues.yaml | 5 +- internal/config/controller.go | 34 ++- internal/queue/controller.go | 218 ++++++++++++------ internal/queue/controller_test.go | 2 +- internal/reporter/msteams/reporter.go | 1 + internal/reporter/slack/reporter.go | 1 + internal/samsahai.go | 2 +- internal/samsahai/controller.go | 2 +- internal/samsahai/internal_process.go | 102 +++++--- internal/samsahai/rpc.go | 10 +- internal/samsahai/webhook/router.go | 2 +- internal/samsahai/webhook/webhook.go | 2 +- internal/staging/collect_result.go | 36 +-- internal/staging/deploy.go | 22 +- internal/staging/image_missing.go | 8 +- 19 files changed, 299 insertions(+), 183 deletions(-) diff --git a/api/v1beta1/desiredcomponent_types.go b/api/v1beta1/desiredcomponent_types.go index 9cb0b2d1..7ef3ed5c 100644 --- a/api/v1beta1/desiredcomponent_types.go +++ b/api/v1beta1/desiredcomponent_types.go @@ -25,6 +25,9 @@ type DesiredComponentSpec struct { Name string `json:"name"` Version string `json:"version"` Repository string `json:"repository"` + + // +Optional + Bundle string `json:"bundle,omitempty"` } // DesiredComponentStatus defines the observed state of DesiredComponent @@ -44,11 +47,11 @@ type DesiredComponent struct { Status DesiredComponentStatus `json:"status,omitempty"` } -// TODO: pohfy, unused? func (c *DesiredComponent) IsSame(d *DesiredComponent) bool { return c.Spec.Name == d.Spec.Name && c.Spec.Repository == d.Spec.Repository && - c.Spec.Version == d.Spec.Version + c.Spec.Version == d.Spec.Version && + c.Spec.Bundle == d.Spec.Bundle } // +kubebuilder:object:root=true diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index ae6cdb1f..7ef8db07 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -94,10 +94,12 @@ type QueueSpec struct { // TODO: pohfy, remove here // Repository represents Docker image repository - Repository string `json:"repository"` + // +optional + Repository string `json:"repository,omitempty"` // Version represents Docker image tag version - Version string `json:"version"` + // +optional + Version string `json:"version,omitempty"` // Type represents how we will process this queue Type QueueType `json:"type"` @@ -308,10 +310,6 @@ func (q *Queue) IsSame(d *Queue) bool { return true } -func (q *Queue) IsInExistBundle(d *Queue) bool { - return q.Spec.Bundle != "" && q.Spec.Bundle == d.Spec.Bundle -} - func (q *Queue) SetState(state QueueState) { now := metav1.Now() q.Status.UpdatedAt = &now @@ -336,17 +334,6 @@ func (q *Queue) IsActivePromotionQueue() bool { q.Spec.Type == QueueTypeDemoteFromActive } -//func (q *Queue) UpdateComponentIfNotExist(d *Queue) string { -// q.Spec.Components.Sort() -// d.Spec.Components.Sort() -// -// for _, dcomp := range d.Spec.Components { -// for _, qcomp := range q.Spec.Components { -// if qcomp.Name != -// } -// } -//} - // GetEnvType returns environment type for connection based on Queue.Spec.Type func (q *Queue) GetEnvType() string { switch q.Spec.Type { diff --git a/config/crds/env.samsahai.io_desiredcomponents.yaml b/config/crds/env.samsahai.io_desiredcomponents.yaml index 6cd4f40d..44ffac44 100644 --- a/config/crds/env.samsahai.io_desiredcomponents.yaml +++ b/config/crds/env.samsahai.io_desiredcomponents.yaml @@ -34,6 +34,8 @@ spec: spec: description: DesiredComponentSpec defines the desired state of DesiredComponent properties: + bundle: + type: string name: type: string repository: diff --git a/config/crds/env.samsahai.io_queuehistories.yaml b/config/crds/env.samsahai.io_queuehistories.yaml index 0c05c4db..bfd35bcf 100644 --- a/config/crds/env.samsahai.io_queuehistories.yaml +++ b/config/crds/env.samsahai.io_queuehistories.yaml @@ -63,8 +63,7 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, name is bundle name QueueSpec defines - the desired state of Queue' + description: QueueSpec defines the desired state of Queue properties: bundle: description: Bundle represents a bundle name of component @@ -123,10 +122,8 @@ spec: - components - name - noOfOrder - - repository - teamName - type - - version type: object status: description: QueueStatus defines the observed state of Queue diff --git a/config/crds/env.samsahai.io_queues.yaml b/config/crds/env.samsahai.io_queues.yaml index 7b5050f9..400f2a69 100644 --- a/config/crds/env.samsahai.io_queues.yaml +++ b/config/crds/env.samsahai.io_queues.yaml @@ -32,8 +32,7 @@ spec: metadata: type: object spec: - description: 'TODO: pohfy, name is bundle name QueueSpec defines the desired - state of Queue' + description: QueueSpec defines the desired state of Queue properties: bundle: description: Bundle represents a bundle name of component @@ -90,10 +89,8 @@ spec: - components - name - noOfOrder - - repository - teamName - type - - version type: object status: description: QueueStatus defines the observed state of Queue diff --git a/internal/config/controller.go b/internal/config/controller.go index a2097d33..1b625f4f 100644 --- a/internal/config/controller.go +++ b/internal/config/controller.go @@ -272,7 +272,7 @@ func (c *controller) ensureComponentChanged(teamName, namespace string) error { return err } - if err := c.detectRemovedQueues(comps, namespace); err != nil { + if err := c.detectRemovedQueues(comps, teamName, namespace); err != nil { return err } @@ -292,7 +292,7 @@ func (c *controller) notifyComponentChanged(teamName, namespace string, comps ma logger.Debug("start notifying components", "team", teamName, "namespace", namespace) for _, comp := range comps { - c.s2hCtrl.NotifyComponentChanged(comp.Name, comp.Image.Repository) + c.s2hCtrl.NotifyComponentChanged(comp.Name, comp.Image.Repository, teamName) } } @@ -351,25 +351,39 @@ func (c *controller) detectRemovedTeamDesiredComponents(comps map[string]*s2hv1b return nil } -func (c *controller) detectRemovedQueues(comps map[string]*s2hv1beta1.Component, namespace string) error { +// TODO: should remove queue from desiredcomponent controller +func (c *controller) detectRemovedQueues(comps map[string]*s2hv1beta1.Component, teamName, namespace string) error { ctx := context.Background() - qComps := &s2hv1beta1.QueueList{} - if err := c.client.List(ctx, qComps, &client.ListOptions{Namespace: namespace}); err != nil { + queueList := &s2hv1beta1.QueueList{} + if err := c.client.List(ctx, queueList, &client.ListOptions{Namespace: namespace}); err != nil { logger.Error(err, "cannot list queues", "namespace", namespace) return err } - for i := len(qComps.Items) - 1; i >= 0; i-- { - q := qComps.Items[i] - if _, ok := comps[q.Name]; !ok { + for i := len(queueList.Items) - 1; i >= 0; i-- { + q := queueList.Items[i] + newComps := make([]*s2hv1beta1.QueueComponent, 0) + for _, qComp := range q.Spec.Components { + if _, ok := comps[qComp.Name]; ok { + newComps = append(newComps, qComp) + } + } + + if len(newComps) == 0 { if err := c.client.Delete(ctx, &q); err != nil { logger.Error(err, "cannot remove queue", "namespace", namespace, "component", q.Name) return err } + } else if len(newComps) != len(q.Spec.Components) { + q.Spec.Components = newComps - logger.Debug("queue has been removed", - "namespace", namespace, "component", q.Name) + // reset NoOfRetry/NextProcessAt if there are removed components + q.Spec.NoOfRetry = 0 + q.Spec.NextProcessAt = nil + if err := c.client.Update(ctx, &q); err != nil { + return err + } } } diff --git a/internal/queue/controller.go b/internal/queue/controller.go index bb5d43d3..894c0543 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -2,6 +2,7 @@ package queue import ( "context" + "fmt" "time" "github.com/pkg/errors" @@ -27,17 +28,22 @@ type controller struct { var _ internal.QueueController = &controller{} func NewUpgradeQueue(teamName, namespace, name, bundle string, comps []*s2hv1beta1.QueueComponent) *s2hv1beta1.Queue { + queueName := name + if bundle != "" { + queueName = bundle + } + qLabels := internal.GetDefaultLabels(teamName) qLabels["app"] = name qLabels["component"] = name return &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ - Name: name, + Name: queueName, Namespace: namespace, Labels: qLabels, }, Spec: s2hv1beta1.QueueSpec{ - Name: name, + Name: queueName, TeamName: teamName, Bundle: bundle, Components: comps, @@ -102,7 +108,6 @@ func (c *controller) Remove(q *s2hv1beta1.Queue) error { } func (c *controller) RemoveAllQueues() error { - return c.client.DeleteAllOf(context.TODO(), &s2hv1beta1.Queue{}, client.InNamespace(c.namespace)) } @@ -119,7 +124,7 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo return nil } - bundleQueue := &s2hv1beta1.Queue{} + //bundleQueue := &s2hv1beta1.Queue{} pQueue := &s2hv1beta1.Queue{} isAlreadyInQueue := false isAlreadyInBundle := false @@ -129,22 +134,40 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo pQueue = &queueList.Items[i] break } - - if q.IsInExistBundle(queue) { - isAlreadyInBundle = true - bundleQueue = &queueList.Items[i] - break - } } // remove duplicate component - removingList := c.removeSimilar(queue, queueList) + removingList := c.removeSimilarExceptBundle(queue, queueList) for i := range removingList { if err := c.client.Delete(ctx, &removingList[i]); err != nil { return err } } + if !isAlreadyInQueue { + pQueue, err = c.updateExistingBundleQueue(ctx, queue, queueList) + if err != nil { + return err + } + if pQueue != nil { + isAlreadyInQueue = true + isAlreadyInBundle = true + } else { + if err = c.addNewBundleQueue(ctx, queue, queueList); err != nil { + return err + } + } + + if err := c.removeInvalidComponentInBundle(ctx, queue, queueList); err != nil { + return err + } + } + + // queue list have been changed + if queueList, err = c.list(nil); err != nil { + logger.Error(err, "cannot list queue") + return err + } queueList.Sort() now := metav1.Now() @@ -156,48 +179,31 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo pQueue.Spec.NoOfOrder = queueList.TopQueueOrder() } - if err = c.client.Update(ctx, pQueue); err != nil { - return err - } - } else { - isNewQueue := true if isAlreadyInBundle { - queue, isNewQueue = c.generateBundleQueue(queue, bundleQueue) // reset NoOfRetry/NextProcessAt if there is new component join the bundle - queue.Spec.NoOfRetry = 0 - queue.Spec.NextProcessAt = nil + pQueue.Spec.NoOfRetry = 0 + pQueue.Spec.NextProcessAt = nil + pQueue.Status.State = s2hv1beta1.Waiting + queue.Status.UpdatedAt = &now } + pQueue.Spec.Components.Sort() + if err = c.client.Update(ctx, pQueue); err != nil { + return err + } + } else { // queue not exist if atTop { queue.Spec.NoOfOrder = queueList.TopQueueOrder() - } else { - if isAlreadyInBundle { - queue.Spec.NoOfOrder = bundleQueue.Spec.NoOfOrder - } else { - queue.Spec.NoOfOrder = queueList.LastQueueOrder() - } } + queue.Spec.NoOfOrder = queueList.LastQueueOrder() queue.Status.State = s2hv1beta1.Waiting queue.Status.CreatedAt = &now queue.Status.UpdatedAt = &now - if isNewQueue { - if err = c.client.Create(ctx, queue); err != nil { - return err - } - - // delete old queue if creating a new bundle queue - if isAlreadyInBundle { - if err = c.client.Delete(ctx, bundleQueue); err != nil { - return err - } - } - return nil - } - - if err = c.client.Update(ctx, queue); err != nil { + queue.Spec.Components.Sort() + if err = c.client.Create(ctx, queue); err != nil { return err } } @@ -212,54 +218,130 @@ func (c *controller) isMatchWithStableComponent(ctx context.Context, q *s2hv1bet return } - qcomp := q.Spec.Components[0] + qComp := q.Spec.Components[0] stableComp := &s2hv1beta1.StableComponent{} - err = c.client.Get(ctx, types.NamespacedName{Namespace: c.namespace, Name: qcomp.Name}, stableComp) + err = c.client.Get(ctx, types.NamespacedName{Namespace: c.namespace, Name: qComp.Name}, stableComp) if err != nil && k8serrors.IsNotFound(err) { return false, nil } else if err != nil { return } - isMatch = stableComp.Spec.Repository == qcomp.Repository && - stableComp.Spec.Version == qcomp.Version + isMatch = stableComp.Spec.Repository == qComp.Repository && + stableComp.Spec.Version == qComp.Version return } -func (c *controller) generateBundleQueue(targetQ *s2hv1beta1.Queue, existBundleQ *s2hv1beta1.Queue) (*s2hv1beta1.Queue, bool) { - isNewBundle := false - newBundleQueue := existBundleQ - if existBundleQ.Name != existBundleQ.Spec.Bundle { // e.g. redis != db - // create new bundle queue - newBundleQueue = NewUpgradeQueue(existBundleQ.Spec.TeamName, existBundleQ.Namespace, existBundleQ.Spec.Bundle, - existBundleQ.Spec.Bundle, existBundleQ.Spec.Components) - isNewBundle = true - } - - // append components if bundle exists - for _, tcomp := range targetQ.Spec.Components { - isFound := false - for j, ecomp := range existBundleQ.Spec.Components { - if ecomp.Name == tcomp.Name { - isFound = true - newBundleQueue.Spec.Components[j].Repository = tcomp.Repository - newBundleQueue.Spec.Components[j].Version = tcomp.Version +// addNewBundleQueue updates queue object and updates/removes existing queue +func (c *controller) addNewBundleQueue(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) error { + if len(queue.Spec.Components) == 0 { + return fmt.Errorf("components should not be empty, queueName: %s", queue.Name) + } + + var found bool + for _, existingQ := range list.Items { + //newComps := make([]*s2hv1beta1.QueueComponent, 0) + for _, existingQComp := range existingQ.Spec.Components { + // existing queue is component queue or different queue bundle name + if existingQ.Spec.Name != queue.Spec.Name && + existingQ.Spec.Bundle != queue.Spec.Bundle && + existingQComp.Name == queue.Spec.Components[0].Name { + + queue = NewUpgradeQueue(queue.Spec.TeamName, queue.Namespace, queue.Spec.Name, + queue.Spec.Bundle, queue.Spec.Components) + + found = true break } } - if !isFound { - newBundleQueue.Spec.Components = append(newBundleQueue.Spec.Components, tcomp) + + if found { + break + } + } + + return nil +} + +// updateExistingBundleQueue returns updated bundle queue +func (c *controller) updateExistingBundleQueue(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) (*s2hv1beta1.Queue, error) { + if len(queue.Spec.Components) == 0 { + return nil, fmt.Errorf("components should not be empty, queueName: %s", queue.Name) + } + + if queue.Spec.Bundle == "" { + return nil, nil + } + + var updatedBundleQueue *s2hv1beta1.Queue + for _, existingQ := range list.Items { + // update component of bundle + if existingQ.Spec.Bundle == queue.Spec.Bundle { + var found bool + updatedBundleQueue = &existingQ + for i, existingQComp := range existingQ.Spec.Components { + if existingQComp.Name == queue.Spec.Components[0].Name { + updatedBundleQueue.Spec.Components[i].Repository = queue.Spec.Components[0].Repository + updatedBundleQueue.Spec.Components[i].Version = queue.Spec.Components[0].Version + found = true + break + } + } + + // add a new component to bundle + if !found { + updatedBundleQueue.Spec.Components = append(updatedBundleQueue.Spec.Components, queue.Spec.Components...) + } + + break } } - newBundleQueue.Spec.Components.Sort() + return updatedBundleQueue, nil +} + +// removeInvalidComponentInBundle removes component which not exist in bundle +func (c *controller) removeInvalidComponentInBundle(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) error { + if len(queue.Spec.Components) == 0 { + return fmt.Errorf("components should not be empty, queueName: %s", queue.Name) + } - return newBundleQueue, isNewBundle + for _, existingQ := range list.Items { + newComps := make([]*s2hv1beta1.QueueComponent, 0) + for _, existingQComp := range existingQ.Spec.Components { + if existingQ.Spec.Bundle != queue.Spec.Bundle && + existingQComp.Name == queue.Spec.Components[0].Name { + continue + } + newComps = append(newComps, existingQComp) + } + + if len(newComps) == 0 { + if err := c.client.Delete(ctx, &existingQ); err != nil { + return err + } + break + } + + if len(newComps) != len(existingQ.Spec.Components) { + existingQ.Spec.Components = newComps + if err := c.client.Update(ctx, &existingQ); err != nil { + return err + } + break + } + } + + return nil } -// removeSimilar removes similar queue (same `name` from queue) from QueueList -func (c *controller) removeSimilar(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) []s2hv1beta1.Queue { +// removeSimilarExceptBundle removes similar queue (same `name` from queue) which is not bundle queue from QueueList +func (c *controller) removeSimilarExceptBundle(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) []s2hv1beta1.Queue { + if queue.Spec.Bundle != "" { + return []s2hv1beta1.Queue{} + } + var items []s2hv1beta1.Queue var removing []s2hv1beta1.Queue var hasSameQueue = false diff --git a/internal/queue/controller_test.go b/internal/queue/controller_test.go index 4c119cc1..caabb40c 100644 --- a/internal/queue/controller_test.go +++ b/internal/queue/controller_test.go @@ -44,7 +44,7 @@ var _ = Describe("Queue Controller", func() { }, } - removing := c.removeSimilar(queue, queueList) + removing := c.removeSimilarExceptBundle(queue, queueList) g.Expect(len(queueList.Items)).To(Equal(1)) g.Expect(len(removing)).To(Equal(2)) diff --git a/internal/reporter/msteams/reporter.go b/internal/reporter/msteams/reporter.go index fd15472f..6ae14a2a 100644 --- a/internal/reporter/msteams/reporter.go +++ b/internal/reporter/msteams/reporter.go @@ -205,6 +205,7 @@ func (r *reporter) makeComponentUpgradeReport(comp *internal.ComponentUpgradeRep
    Issue type: {{ .IssueTypeStr }} {{- end }}
    Run:{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }} +
    Queue: {{ .Name }}
    Components {{- range .Components }}
  • - Name: {{ .Name }}
  • diff --git a/internal/reporter/slack/reporter.go b/internal/reporter/slack/reporter.go index e26bb0eb..54492200 100644 --- a/internal/reporter/slack/reporter.go +++ b/internal/reporter/slack/reporter.go @@ -201,6 +201,7 @@ func (r *reporter) makeComponentUpgradeReport(comp *internal.ComponentUpgradeRep *Issue type:* {{ .IssueTypeStr }} {{- end }} *Run:*{{ if .IsReverify }} Reverify {{ else }} #{{ .Runs }} {{ end }} +*Queue:* {{ .Name }} *Components* {{- range .Components }} >- *Name:* {{ .Name }} diff --git a/internal/samsahai.go b/internal/samsahai.go index 6dc1fc50..2ff94ff5 100644 --- a/internal/samsahai.go +++ b/internal/samsahai.go @@ -156,7 +156,7 @@ type SamsahaiController interface { SetActiveNamespace(teamComp *s2hv1beta1.Team, namespace string) error // NotifyComponentChanged adds Component to queue for checking new version - NotifyComponentChanged(name, repository string) + NotifyComponentChanged(name, repository, teamName string) // NotifyActivePromotion sends active promotion status report NotifyActivePromotion(atpRpt *ActivePromotionReporter) diff --git a/internal/samsahai/controller.go b/internal/samsahai/controller.go index 0cb2b731..f550906d 100644 --- a/internal/samsahai/controller.go +++ b/internal/samsahai/controller.go @@ -958,7 +958,7 @@ func (c *controller) notifyComponentChanged(teamName string) error { } for comp := range comps { - c.NotifyComponentChanged(comp, "") + c.NotifyComponentChanged(comp, "", teamName) } return nil diff --git a/internal/samsahai/internal_process.go b/internal/samsahai/internal_process.go index dc897586..3f75db75 100644 --- a/internal/samsahai/internal_process.go +++ b/internal/samsahai/internal_process.go @@ -23,6 +23,7 @@ const maxDesiredMappingPerComp = 10 type changedComponent struct { Name string Repository string + TeamName string } type updateHealth struct { @@ -37,6 +38,7 @@ type updateTeamDesiredComponent struct { ComponentName string ComponentSource string ComponentImage s2hv1beta1.ComponentImage + ComponentBundle string } func (c *controller) Start(stop <-chan struct{}) { @@ -60,10 +62,11 @@ func (c *controller) Start(stop <-chan struct{}) { logger.Info("stopping internal process") } -func (c *controller) NotifyComponentChanged(compName, repository string) { +func (c *controller) NotifyComponentChanged(compName, repository, teamName string) { c.queue.Add(changedComponent{ Repository: repository, Name: compName, + TeamName: teamName, }) } @@ -105,57 +108,75 @@ func (c *controller) process() bool { return true } -// TODO: pohfy, check bundle changed // checkComponentChanged checks matched components from every teams and add to queue for checking new version. // // Component should match both name and repository func (c *controller) checkComponentChanged(component changedComponent) error { - configCtrl := c.GetConfigController() - teamList, err := c.GetTeams() - if err != nil { - return err - } - - for _, teamComp := range teamList.Items { - teamName := teamComp.Name - team := &s2hv1beta1.Team{} - if err := c.getTeam(teamName, team); err != nil { - logger.Error(err, "cannot get team", "team", teamName) + if component.TeamName != "" { + if err := c.checkTeamComponentChanged(component.Name, component.Repository, component.TeamName); err != nil { + logger.Error(err, "cannot check component changed", "team", component.TeamName) + return err + } + } else { + teamList, err := c.GetTeams() + if err != nil { return err } - comps, _ := configCtrl.GetComponents(teamName) - for _, comp := range comps { - if component.Name != comp.Name || comp.Source == nil { - // ignored mismatch or missing source + for _, teamComp := range teamList.Items { + teamName := teamComp.Name + if err := c.checkTeamComponentChanged(component.Name, component.Repository, teamName); err != nil { + logger.Error(err, "cannot check component changed", "team", teamName) continue } + } + } - if _, ok := c.checkers[string(*comp.Source)]; !ok { - // ignore non-existing source - continue - } + return nil +} - if component.Repository != "" && component.Repository != comp.Image.Repository { - // ignore mismatch repository - continue - } +// TODO: pohfy, check bundle changed +func (c *controller) checkTeamComponentChanged(compName, repository, teamName string) error { + configCtrl := c.GetConfigController() + team := &s2hv1beta1.Team{} + if err := c.getTeam(teamName, team); err != nil { + logger.Error(err, "cannot get team", "team", teamName) + return err + } - logger.Debug("component has been notified", "team", teamName, "component", comp.Name) + comps, _ := configCtrl.GetComponents(teamName) + for _, comp := range comps { + if compName != comp.Name || comp.Source == nil { + // ignored mismatch or missing source + continue + } - // add to queue for processing - c.queue.Add(updateTeamDesiredComponent{ - TeamName: teamName, - ComponentName: comp.Name, - ComponentSource: string(*comp.Source), - ComponentImage: comp.Image, - }) + if _, ok := c.checkers[string(*comp.Source)]; !ok { + // ignore non-existing source + continue } + + if repository != "" && repository != comp.Image.Repository { + // ignore mismatch repository + continue + } + + logger.Debug("component has been notified", "team", teamName, "component", comp.Name) + + // add to queue for processing + bundleName := c.getBundleName(comp.Name, teamName) + c.queue.Add(updateTeamDesiredComponent{ + TeamName: teamName, + ComponentName: comp.Name, + ComponentSource: string(*comp.Source), + ComponentImage: comp.Image, + ComponentBundle: bundleName, + }) } + return nil } -// TODO: pohfy, this place call desired component // updateTeamDesiredComponent gets new version from checker and checks with DesiredComponent of team. // // updateInfo will always has valid checker (from checkComponentChanged) @@ -177,6 +198,7 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp compNs := team.Status.Namespace.Staging compName := updateInfo.ComponentName compRepository := updateInfo.ComponentImage.Repository + compBundle := updateInfo.ComponentBundle // TODO: do caching for better performance version, vErr := checker.GetVersion(compRepository, compName, checkPattern) @@ -227,6 +249,7 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp Version: version, Name: compName, Repository: compRepository, + Bundle: compBundle, }, Status: s2hv1beta1.DesiredComponentStatus{ CreatedAt: &now, @@ -247,13 +270,22 @@ func (c *controller) updateTeamDesiredComponent(updateInfo updateTeamDesiredComp } // DesiredComponent found, check the version - if desiredComp.Spec.Version == version && desiredComp.Spec.Repository == compRepository { + sameComp := desiredComp.IsSame(&s2hv1beta1.DesiredComponent{ + Spec: s2hv1beta1.DesiredComponentSpec{ + Name: compName, + Version: version, + Repository: compRepository, + Bundle: compBundle, + }, + }) + if sameComp { return nil } // Update when version or repository changed desiredComp.Spec.Version = version desiredComp.Spec.Repository = compRepository + desiredComp.Spec.Bundle = compBundle desiredComp.Status.UpdatedAt = &now if err = c.client.Update(ctx, desiredComp); err != nil { diff --git a/internal/samsahai/rpc.go b/internal/samsahai/rpc.go index d78800f2..7c7f56ec 100644 --- a/internal/samsahai/rpc.go +++ b/internal/samsahai/rpc.go @@ -68,8 +68,8 @@ func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWi // ignore current component isFound := false - for _, qcomp := range teamInfo.Components { - if qcomp.Name == stable.Name { + for _, qComp := range teamInfo.Components { + if qComp.Name == stable.Name { isFound = true break } @@ -82,10 +82,10 @@ func (c *controller) GetMissingVersion(ctx context.Context, teamInfo *rpc.TeamWi } // get image missing of current components - for _, qcomp := range teamInfo.Components { - source, ok := c.getImageSource(comps, qcomp.Name) + for _, qComp := range teamInfo.Components { + source, ok := c.getImageSource(comps, qComp.Name) if ok { - c.detectAndAddImageMissing(*source, qcomp.Image.Repository, qcomp.Name, qcomp.Image.Tag, imgList) + c.detectAndAddImageMissing(*source, qComp.Image.Repository, qComp.Name, qComp.Image.Tag, imgList) } } diff --git a/internal/samsahai/webhook/router.go b/internal/samsahai/webhook/router.go index 9b951e2b..8277ce99 100644 --- a/internal/samsahai/webhook/router.go +++ b/internal/samsahai/webhook/router.go @@ -211,7 +211,7 @@ func (h *handler) newComponentWebhook(w http.ResponseWriter, r *http.Request, pa h.error(w, http.StatusBadRequest, s2herrors.ErrInvalidJSONData) return } - h.samsahai.NotifyComponentChanged(jsonData.Component, jsonData.Repository) + h.samsahai.NotifyComponentChanged(jsonData.Component, jsonData.Repository, "") w.WriteHeader(http.StatusNoContent) } diff --git a/internal/samsahai/webhook/webhook.go b/internal/samsahai/webhook/webhook.go index c2507e6a..2d29ed75 100644 --- a/internal/samsahai/webhook/webhook.go +++ b/internal/samsahai/webhook/webhook.go @@ -33,7 +33,7 @@ var pluginWebhookFunc = func(h *handler, plugin internal.Plugin) func(w http.Res "reqData", string(data), "component", jsonData.Component, "output", compName) - h.samsahai.NotifyComponentChanged(compName, "") + h.samsahai.NotifyComponentChanged(compName, "", "") } w.WriteHeader(http.StatusNoContent) diff --git a/internal/staging/collect_result.go b/internal/staging/collect_result.go index 6fad0039..a26d66b9 100644 --- a/internal/staging/collect_result.go +++ b/internal/staging/collect_result.go @@ -191,26 +191,26 @@ func (c *controller) deleteQueueHistoryOutOfRange(ctx context.Context, namespace func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { const updatedBy = "samsahai" - for _, qcomp := range queue.Spec.Components { + for _, qComp := range queue.Spec.Components { stableComp := &s2hv1beta1.StableComponent{} err = c.client.Get( context.TODO(), - types.NamespacedName{Namespace: queue.GetNamespace(), Name: qcomp.Name}, + types.NamespacedName{Namespace: queue.GetNamespace(), Name: qComp.Name}, stableComp) if err != nil && k8serrors.IsNotFound(err) { now := metav1.Now() stableLabels := internal.GetDefaultLabels(c.teamName) - stableLabels["app"] = qcomp.Name + stableLabels["app"] = qComp.Name stableComp := &s2hv1beta1.StableComponent{ ObjectMeta: metav1.ObjectMeta{ - Name: qcomp.Name, + Name: qComp.Name, Namespace: queue.Namespace, Labels: stableLabels, }, Spec: s2hv1beta1.StableComponentSpec{ - Name: qcomp.Name, - Version: qcomp.Version, - Repository: qcomp.Repository, + Name: qComp.Name, + Version: qComp.Version, + Repository: qComp.Repository, UpdatedBy: updatedBy, }, Status: s2hv1beta1.StableComponentStatus{ @@ -220,30 +220,30 @@ func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { } err = c.client.Create(context.TODO(), stableComp) if err != nil { - logger.Error(err, fmt.Sprintf("cannot create StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + logger.Error(err, fmt.Sprintf("cannot create StableComponent: %s/%s", queue.GetNamespace(), qComp.Name)) return } return nil } else if err != nil { - logger.Error(err, fmt.Sprintf("cannot get StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + logger.Error(err, fmt.Sprintf("cannot get StableComponent: %s/%s", queue.GetNamespace(), qComp.Name)) return err } - if stableComp.Spec.Version == qcomp.Version && - stableComp.Spec.Repository == qcomp.Repository { + if stableComp.Spec.Version == qComp.Version && + stableComp.Spec.Repository == qComp.Repository { // no change return nil } - stableComp.Spec.Repository = qcomp.Repository - stableComp.Spec.Version = qcomp.Version + stableComp.Spec.Repository = qComp.Repository + stableComp.Spec.Version = qComp.Version stableComp.Spec.UpdatedBy = updatedBy err = c.client.Update(context.TODO(), stableComp) if err != nil { - logger.Error(err, fmt.Sprintf("cannot update StableComponent: %s/%s", queue.GetNamespace(), qcomp.Name)) + logger.Error(err, fmt.Sprintf("cannot update StableComponent: %s/%s", queue.GetNamespace(), qComp.Name)) return } } @@ -394,12 +394,12 @@ func (c *controller) sendComponentUpgradeReport(status rpc.ComponentUpgrade_Upgr } rpcComps := make([]*rpc.Component, 0) - for _, qcomp := range queue.Spec.Components { + for _, qComp := range queue.Spec.Components { rpcComps = append(rpcComps, &rpc.Component{ - Name: qcomp.Name, + Name: qComp.Name, Image: &rpc.Image{ - Repository: qcomp.Repository, - Tag: qcomp.Version, + Repository: qComp.Repository, + Tag: qComp.Version, }, }) } diff --git a/internal/staging/deploy.go b/internal/staging/deploy.go index 5fcba7af..e00be9d2 100644 --- a/internal/staging/deploy.go +++ b/internal/staging/deploy.go @@ -57,18 +57,18 @@ func (c *controller) deployEnvironment(queue *s2hv1beta1.Queue) error { } newComps := make([]*s2hv1beta1.QueueComponent, 0) - for _, qcomp := range queue.Spec.Components { - comp, ok := comps[qcomp.Name] + for _, qComp := range queue.Spec.Components { + comp, ok := comps[qComp.Name] if !ok { continue } - newComps = append(newComps, qcomp) - queueComps[qcomp.Name] = comp - queueParentComps[qcomp.Name] = comp + newComps = append(newComps, qComp) + queueComps[qComp.Name] = comp + queueParentComps[qComp.Name] = comp if comp.Parent != "" { - delete(queueParentComps, qcomp.Name) + delete(queueParentComps, qComp.Name) queueParentComps[comp.Parent] = comps[comp.Parent] } } @@ -197,13 +197,13 @@ func (c *controller) getStableComponentsMap() (stableMap map[string]s2hv1beta1.S return } -func genCompValueFromQueue(compName string, qcomps []*s2hv1beta1.QueueComponent) map[string]interface{} { - for _, qcomp := range qcomps { - if qcomp.Name == compName { +func genCompValueFromQueue(compName string, qComps []*s2hv1beta1.QueueComponent) map[string]interface{} { + for _, qComp := range qComps { + if qComp.Name == compName { return map[string]interface{}{ "image": map[string]interface{}{ - "repository": qcomp.Repository, - "tag": qcomp.Version, + "repository": qComp.Repository, + "tag": qComp.Version, }, } } diff --git a/internal/staging/image_missing.go b/internal/staging/image_missing.go index 09fca3fa..d0f37017 100644 --- a/internal/staging/image_missing.go +++ b/internal/staging/image_missing.go @@ -24,12 +24,12 @@ func (c *controller) detectImageMissing(queue *s2hv1beta1.Queue) error { } rpcComps := make([]*rpc.Component, 0) - for _, qcomp := range queue.Spec.Components { + for _, qComp := range queue.Spec.Components { rpcComps = append(rpcComps, &rpc.Component{ - Name: qcomp.Name, + Name: qComp.Name, Image: &rpc.Image{ - Repository: qcomp.Repository, - Tag: qcomp.Version, + Repository: qComp.Repository, + Tag: qComp.Version, }, }) } From 3b2519db1c8952b53b23902b12f8eda90e99bea5 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 02:57:12 +0700 Subject: [PATCH 07/12] :construction: Update queue metric --- api/v1beta1/queue_types.go | 9 --------- .../crds/env.samsahai.io_queuehistories.yaml | 7 ------- config/crds/env.samsahai.io_queues.yaml | 7 ------- internal/samsahai/exporter/metric.go | 19 +++++++++++-------- .../staging/testrunner/teamcity/testrunner.go | 10 +++++++--- 5 files changed, 18 insertions(+), 34 deletions(-) diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 7ef8db07..6ca3ee51 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -92,15 +92,6 @@ type QueueSpec struct { // Components represents a list of components which are deployed Components QueueComponents `json:"components"` - // TODO: pohfy, remove here - // Repository represents Docker image repository - // +optional - Repository string `json:"repository,omitempty"` - - // Version represents Docker image tag version - // +optional - Version string `json:"version,omitempty"` - // Type represents how we will process this queue Type QueueType `json:"type"` diff --git a/config/crds/env.samsahai.io_queuehistories.yaml b/config/crds/env.samsahai.io_queuehistories.yaml index bfd35bcf..33e09528 100644 --- a/config/crds/env.samsahai.io_queuehistories.yaml +++ b/config/crds/env.samsahai.io_queuehistories.yaml @@ -105,19 +105,12 @@ spec: description: NoOfRetry defines how many times this component has been tested type: integer - repository: - description: 'TODO: pohfy, remove here Repository represents - Docker image repository' - type: string teamName: description: TeamName represents team owner of the queue type: string type: description: Type represents how we will process this queue type: string - version: - description: Version represents Docker image tag version - type: string required: - components - name diff --git a/config/crds/env.samsahai.io_queues.yaml b/config/crds/env.samsahai.io_queues.yaml index 400f2a69..9c56aa51 100644 --- a/config/crds/env.samsahai.io_queues.yaml +++ b/config/crds/env.samsahai.io_queues.yaml @@ -72,19 +72,12 @@ spec: description: NoOfRetry defines how many times this component has been tested type: integer - repository: - description: 'TODO: pohfy, remove here Repository represents Docker - image repository' - type: string teamName: description: TeamName represents team owner of the queue type: string type: description: Type represents how we will process this queue type: string - version: - description: Version represents Docker image tag version - type: string required: - components - name diff --git a/internal/samsahai/exporter/metric.go b/internal/samsahai/exporter/metric.go index c1f31230..3eef6e3f 100644 --- a/internal/samsahai/exporter/metric.go +++ b/internal/samsahai/exporter/metric.go @@ -42,7 +42,7 @@ var HealthStatusMetric = prometheus.NewGaugeVec(prometheus.GaugeOpts{ var QueueMetric = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "samsahai_queue", Help: "Show components in queue", -}, []string{"teamName", "component", "version", "state", "order", "no_of_processed"}) +}, []string{"teamName", "queueName", "component", "version", "state", "order", "no_of_processed"}) var ActivePromotionMetric = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "samsahai_active_promotion", @@ -83,13 +83,16 @@ func SetQueueMetric(queue *s2hv1beta1.Queue) { queueState = queueStateFinished } - QueueMetric.WithLabelValues( - queue.Spec.TeamName, - queue.Name, - queue.Spec.Version, - string(queueState), - strconv.Itoa(queue.Spec.NoOfOrder), - strconv.Itoa(queue.Status.NoOfProcessed)).Set(float64(time.Now().Unix())) + for _, qComp := range queue.Spec.Components { + QueueMetric.WithLabelValues( + queue.Spec.TeamName, + queue.Name, + qComp.Name, + qComp.Version, + string(queueState), + strconv.Itoa(queue.Spec.NoOfOrder), + strconv.Itoa(queue.Status.NoOfProcessed)).Set(float64(time.Now().Unix())) + } } func SetActivePromotionMetric(atpComp *s2hv1beta1.ActivePromotion) { diff --git a/internal/staging/testrunner/teamcity/testrunner.go b/internal/staging/testrunner/teamcity/testrunner.go index 64e1e5d4..67bee1f1 100644 --- a/internal/staging/testrunner/teamcity/testrunner.go +++ b/internal/staging/testrunner/teamcity/testrunner.go @@ -121,6 +121,10 @@ func (t *testRunner) Trigger(testConfig *v1beta1.ConfigTestRunner, currentQueue go func() { apiURL := fmt.Sprintf("%s/%s/buildQueue", t.baseURL, baseAPIPath) teamName := currentQueue.Spec.TeamName + compVersion := "multiple-components" + if len(currentQueue.Spec.Components) == 1 { + compVersion = currentQueue.Spec.Components[0].Version + } reqJSON := &triggerBuildReq{ BranchName: testConfig.Teamcity.Branch, BuildType: buildTypeJSON{ @@ -146,9 +150,9 @@ func (t *testRunner) Trigger(testConfig *v1beta1.ConfigTestRunner, currentQueue {Name: ParamCompName, Value: currentQueue.Name}, {Name: EnvParamCompName, Value: currentQueue.Name}, {Name: ParamReverseCompName, Value: currentQueue.Name}, - {Name: ParamCompVersion, Value: currentQueue.Spec.Version}, - {Name: EnvParamCompVersion, Value: currentQueue.Spec.Version}, - {Name: ParamReverseCompVersion, Value: currentQueue.Spec.Version}, + {Name: ParamCompVersion, Value: compVersion}, + {Name: EnvParamCompVersion, Value: compVersion}, + {Name: ParamReverseCompVersion, Value: compVersion}, {Name: ParamQueueType, Value: currentQueue.GetQueueType()}, {Name: EnvParamQueueType, Value: currentQueue.GetQueueType()}, {Name: ParamReverseQueueType, Value: currentQueue.GetQueueType()}, From 006add58b230704f975dca3a372028cb7643d439 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 12:35:12 +0700 Subject: [PATCH 08/12] :white_check_mark: Update unit tests --- api/v1beta1/queue_types.go | 24 +-- .../crds/env.samsahai.io_queuehistories.yaml | 1 - config/crds/env.samsahai.io_queues.yaml | 1 - internal/config/controller_test.go | 4 +- internal/queue/controller.go | 204 +++++++----------- internal/queue/controller_test.go | 177 ++++++++++++--- internal/reporter/msteams/reporter_test.go | 60 +++++- internal/reporter/rest/reporter_test.go | 38 +++- internal/reporter/shell/reporter_test.go | 4 + internal/reporter/slack/reporter_test.go | 59 ++++- .../samsahai/checker/harbor/checker_test.go | 6 +- .../checker/publicregistry/checker_test.go | 2 +- .../samsahai/checker/samsahai/check_test.go | 10 +- internal/samsahai/exporter/metric_test.go | 31 ++- internal/samsahai/internal_process.go | 1 - internal/samsahai/plugin/plugin_test.go | 4 +- internal/samsahai/rpc.go | 9 +- internal/samsahai/webhook/webhook_test.go | 30 +-- internal/staging/controller_test.go | 8 +- internal/util/dotaccess/dotaccess_test.go | 2 +- internal/util/map_test.go | 2 +- internal/util/msteams/msteams_test.go | 14 +- internal/util/protostruct/unit_test.go | 2 +- test/e2e/queue/ctrl.go | 10 +- 24 files changed, 455 insertions(+), 248 deletions(-) diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 6ca3ee51..191cb556 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -90,7 +90,8 @@ type QueueSpec struct { Bundle string `json:"bundle,omitempty"` // Components represents a list of components which are deployed - Components QueueComponents `json:"components"` + // +optional + Components QueueComponents `json:"components,omitempty"` // Type represents how we will process this queue Type QueueType `json:"type"` @@ -280,25 +281,20 @@ type Queue struct { Status QueueStatus `json:"status,omitempty"` } -func (q *Queue) IsSame(d *Queue) bool { - if q.Spec.Name != d.Spec.Name { - return false - } - - if len(q.Spec.Components) != len(d.Spec.Components) { +func (q *Queue) IsSameComponent(dName string, dComp *QueueComponent) bool { + if dName != q.Spec.Name { return false } - // expect component already sorted - for i := range d.Spec.Components { - if q.Spec.Components[i].Name != d.Spec.Components[i].Name || - q.Spec.Components[i].Repository != d.Spec.Components[i].Repository || - q.Spec.Components[i].Version != d.Spec.Components[i].Version { - return false + for _, qComp := range q.Spec.Components { + if qComp.Name == dComp.Name && + qComp.Repository == dComp.Repository && + qComp.Version == dComp.Version { + return true } } - return true + return false } func (q *Queue) SetState(state QueueState) { diff --git a/config/crds/env.samsahai.io_queuehistories.yaml b/config/crds/env.samsahai.io_queuehistories.yaml index 33e09528..45b86954 100644 --- a/config/crds/env.samsahai.io_queuehistories.yaml +++ b/config/crds/env.samsahai.io_queuehistories.yaml @@ -112,7 +112,6 @@ spec: description: Type represents how we will process this queue type: string required: - - components - name - noOfOrder - teamName diff --git a/config/crds/env.samsahai.io_queues.yaml b/config/crds/env.samsahai.io_queues.yaml index 9c56aa51..1141731b 100644 --- a/config/crds/env.samsahai.io_queues.yaml +++ b/config/crds/env.samsahai.io_queues.yaml @@ -79,7 +79,6 @@ spec: description: Type represents how we will process this queue type: string required: - - components - name - noOfOrder - teamName diff --git a/internal/config/controller_test.go b/internal/config/controller_test.go index 8e1c8e07..655ff1e4 100644 --- a/internal/config/controller_test.go +++ b/internal/config/controller_test.go @@ -57,7 +57,7 @@ var _ = Describe("Config Controller", func() { }, } - It("Should get env values by the env type correctly", func() { + It("should get env values by the env type correctly", func() { g := NewWithT(GinkgoT()) config := mockConfig @@ -75,7 +75,7 @@ var _ = Describe("Config Controller", func() { })) }) - It("Should get env values by the env type and component name correctly", func() { + It("should get env values by the env type and component name correctly", func() { g := NewWithT(GinkgoT()) config := mockConfig diff --git a/internal/queue/controller.go b/internal/queue/controller.go index 894c0543..0b22342a 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -111,7 +111,12 @@ func (c *controller) RemoveAllQueues() error { return c.client.DeleteAllOf(context.TODO(), &s2hv1beta1.Queue{}, client.InNamespace(c.namespace)) } +// `queue` always contains 1 component func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop bool) error { + if len(queue.Spec.Components) == 0 { + return fmt.Errorf("components should not be empty, queueName: %s", queue.Name) + } + queueList, err := c.list(nil) if err != nil { logger.Error(err, "cannot list queue") @@ -129,69 +134,62 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo isAlreadyInQueue := false isAlreadyInBundle := false for i, q := range queueList.Items { - if q.IsSame(queue) { + if q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { isAlreadyInQueue = true pQueue = &queueList.Items[i] break } } - // remove duplicate component - removingList := c.removeSimilarExceptBundle(queue, queueList) + // remove/update duplicate component + removingList, updatingList := c.removeAndUpdateSimilarQueue(queue, queueList) for i := range removingList { if err := c.client.Delete(ctx, &removingList[i]); err != nil { return err } } - - if !isAlreadyInQueue { - pQueue, err = c.updateExistingBundleQueue(ctx, queue, queueList) - if err != nil { + for i := range updatingList { + updatingList[i].Spec.Components.Sort() + updatingList[i].Spec.NoOfRetry = 0 + updatingList[i].Spec.NextProcessAt = nil + updatingList[i].Status.State = s2hv1beta1.Waiting + updatingList[i].Spec.Components.Sort() + if err := c.client.Update(ctx, &updatingList[i]); err != nil { return err } - if pQueue != nil { - isAlreadyInQueue = true - isAlreadyInBundle = true - } else { - if err = c.addNewBundleQueue(ctx, queue, queueList); err != nil { - return err - } - } + } - if err := c.removeInvalidComponentInBundle(ctx, queue, queueList); err != nil { + updatingList = c.addExistingBundleQueue(queue, queueList) + for i := range updatingList { + isAlreadyInBundle = true + updatingList[i].Spec.NoOfRetry = 0 + updatingList[i].Spec.NextProcessAt = nil + updatingList[i].Status.State = s2hv1beta1.Waiting + updatingList[i].Spec.Components.Sort() + if err := c.client.Update(ctx, &updatingList[i]); err != nil { return err } } - // queue list have been changed - if queueList, err = c.list(nil); err != nil { - logger.Error(err, "cannot list queue") - return err - } queueList.Sort() now := metav1.Now() if isAlreadyInQueue { - isQueueOnTop := pQueue.IsSame(&queueList.Items[0]) + var isQueueOnTop bool + if len(queueList.Items[0].Spec.Components) > 0 { + isQueueOnTop = pQueue.IsSameComponent(queueList.Items[0].Spec.Name, queueList.Items[0].Spec.Components[0]) + } // move queue to the top if atTop && !isQueueOnTop { pQueue.Spec.NoOfOrder = queueList.TopQueueOrder() } - if isAlreadyInBundle { - // reset NoOfRetry/NextProcessAt if there is new component join the bundle - pQueue.Spec.NoOfRetry = 0 - pQueue.Spec.NextProcessAt = nil - pQueue.Status.State = s2hv1beta1.Waiting - queue.Status.UpdatedAt = &now - } - pQueue.Spec.Components.Sort() if err = c.client.Update(ctx, pQueue); err != nil { return err } - } else { + } else if !isAlreadyInBundle { // queue not exist if atTop { queue.Spec.NoOfOrder = queueList.TopQueueOrder() @@ -233,57 +231,26 @@ func (c *controller) isMatchWithStableComponent(ctx context.Context, q *s2hv1bet return } -// addNewBundleQueue updates queue object and updates/removes existing queue -func (c *controller) addNewBundleQueue(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) error { - if len(queue.Spec.Components) == 0 { - return fmt.Errorf("components should not be empty, queueName: %s", queue.Name) - } - - var found bool - for _, existingQ := range list.Items { - //newComps := make([]*s2hv1beta1.QueueComponent, 0) - for _, existingQComp := range existingQ.Spec.Components { - // existing queue is component queue or different queue bundle name - if existingQ.Spec.Name != queue.Spec.Name && - existingQ.Spec.Bundle != queue.Spec.Bundle && - existingQComp.Name == queue.Spec.Components[0].Name { - - queue = NewUpgradeQueue(queue.Spec.TeamName, queue.Namespace, queue.Spec.Name, - queue.Spec.Bundle, queue.Spec.Components) - - found = true - break - } - } - - if found { - break - } - } - - return nil -} - -// updateExistingBundleQueue returns updated bundle queue -func (c *controller) updateExistingBundleQueue(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) (*s2hv1beta1.Queue, error) { - if len(queue.Spec.Components) == 0 { - return nil, fmt.Errorf("components should not be empty, queueName: %s", queue.Name) - } - +// addExistingBundleQueue returns updated bundle queue list +func (c *controller) addExistingBundleQueue(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) []s2hv1beta1.Queue { if queue.Spec.Bundle == "" { - return nil, nil + return []s2hv1beta1.Queue{} } - var updatedBundleQueue *s2hv1beta1.Queue - for _, existingQ := range list.Items { - // update component of bundle - if existingQ.Spec.Bundle == queue.Spec.Bundle { + var items []s2hv1beta1.Queue + var updating []s2hv1beta1.Queue + var hasSameQueue = false + for _, q := range list.Items { + if !hasSameQueue && q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { + // only add one `queue` to items + hasSameQueue = true + // update component of bundle + } else if q.Spec.Bundle == queue.Spec.Bundle { var found bool - updatedBundleQueue = &existingQ - for i, existingQComp := range existingQ.Spec.Components { - if existingQComp.Name == queue.Spec.Components[0].Name { - updatedBundleQueue.Spec.Components[i].Repository = queue.Spec.Components[0].Repository - updatedBundleQueue.Spec.Components[i].Version = queue.Spec.Components[0].Version + for i, qComp := range q.Spec.Components { + if qComp.Name == queue.Spec.Components[0].Name { + q.Spec.Components[i].Repository = queue.Spec.Components[0].Repository + q.Spec.Components[i].Version = queue.Spec.Components[0].Version found = true break } @@ -291,74 +258,57 @@ func (c *controller) updateExistingBundleQueue(ctx context.Context, queue *s2hv1 // add a new component to bundle if !found { - updatedBundleQueue.Spec.Components = append(updatedBundleQueue.Spec.Components, queue.Spec.Components...) - } - - break - } - } - - return updatedBundleQueue, nil -} - -// removeInvalidComponentInBundle removes component which not exist in bundle -func (c *controller) removeInvalidComponentInBundle(ctx context.Context, queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) error { - if len(queue.Spec.Components) == 0 { - return fmt.Errorf("components should not be empty, queueName: %s", queue.Name) - } - - for _, existingQ := range list.Items { - newComps := make([]*s2hv1beta1.QueueComponent, 0) - for _, existingQComp := range existingQ.Spec.Components { - if existingQ.Spec.Bundle != queue.Spec.Bundle && - existingQComp.Name == queue.Spec.Components[0].Name { - continue + q.Spec.Components = append(q.Spec.Components, queue.Spec.Components[0]) } - newComps = append(newComps, existingQComp) - } - if len(newComps) == 0 { - if err := c.client.Delete(ctx, &existingQ); err != nil { - return err - } - break + updating = append(updating, q) } - if len(newComps) != len(existingQ.Spec.Components) { - existingQ.Spec.Components = newComps - if err := c.client.Update(ctx, &existingQ); err != nil { - return err - } - break - } + items = append(items, q) } - return nil + list.Items = items + return updating } -// removeSimilarExceptBundle removes similar queue (same `name` from queue) which is not bundle queue from QueueList -func (c *controller) removeSimilarExceptBundle(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) []s2hv1beta1.Queue { - if queue.Spec.Bundle != "" { - return []s2hv1beta1.Queue{} - } +// removeAndUpdateSimilarQueue removes similar component/queue (same `component name` from queue) from QueueList +func (c *controller) removeAndUpdateSimilarQueue(queue *s2hv1beta1.Queue, list *s2hv1beta1.QueueList) ( + removing []s2hv1beta1.Queue, updating []s2hv1beta1.Queue) { var items []s2hv1beta1.Queue - var removing []s2hv1beta1.Queue var hasSameQueue = false for _, q := range list.Items { - if !hasSameQueue && q.IsSame(queue) { + // if existing queue is bundle queue, these queues will not be the same since + // `queue` always contains 1 component + if !hasSameQueue && q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { // only add one `queue` to items hasSameQueue = true - } else if q.Spec.Name == queue.Spec.Name { - // remove all the name with `queue` - removing = append(removing, q) - continue + } else { + newComps := make([]*s2hv1beta1.QueueComponent, 0) + for _, qComp := range q.Spec.Components { + if qComp.Name == queue.Spec.Components[0].Name { + continue + } + newComps = append(newComps, qComp) + } + + if len(newComps) == 0 { + removing = append(removing, q) + continue + } + + if len(newComps) != len(q.Spec.Components) { + q.Spec.Components = newComps + updating = append(updating, q) + } } + items = append(items, q) } + list.Items = items - return removing + return } func (c *controller) list(opts *client.ListOptions) (list *s2hv1beta1.QueueList, err error) { diff --git a/internal/queue/controller_test.go b/internal/queue/controller_test.go index caabb40c..a8da8cd3 100644 --- a/internal/queue/controller_test.go +++ b/internal/queue/controller_test.go @@ -16,42 +16,163 @@ func TestQueue(t *testing.T) { } var _ = Describe("Queue Controller", func() { - It("Should remove similar Queue", func() { - - g := NewWithT(GinkgoT()) - - c := controller{} - name := "alpine" - - queue := &v1beta1.Queue{ - Spec: v1beta1.QueueSpec{Name: name, Repository: name, Version: "3.9.4"}, - Status: v1beta1.QueueStatus{}, - } - queueList := &v1beta1.QueueList{ - Items: []v1beta1.Queue{ - { - Spec: v1beta1.QueueSpec{Name: name, Repository: name, Version: "3.9.0"}, - Status: v1beta1.QueueStatus{}, + Describe("Remove/Update similar Queue", func() { + It("should remove similar component Queue", func() { + + g := NewWithT(GinkgoT()) + + c := controller{} + name := "alpine" + + queue := &v1beta1.Queue{ + Spec: v1beta1.QueueSpec{Name: name, Bundle: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.4"}}, }, - { - Spec: v1beta1.QueueSpec{Name: name, Repository: name, Version: "3.9.1"}, - Status: v1beta1.QueueStatus{}, + Status: v1beta1.QueueStatus{}, + } + queueList := &v1beta1.QueueList{ + Items: []v1beta1.Queue{ + { + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.0"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + { + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.1"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + { + Spec: v1beta1.QueueSpec{Name: "group", Bundle: "group", + Components: v1beta1.QueueComponents{ + {Name: name, Repository: name, Version: "3.9.1"}, + {Name: "ubuntu", Repository: "ubuntu", Version: "18.04"}, + }, + }, + Status: v1beta1.QueueStatus{}, + }, + { + Spec: v1beta1.QueueSpec{Name: "ubuntu", + Components: v1beta1.QueueComponents{{Name: "ubuntu", Repository: "ubuntu", Version: "18.04"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + }, + } + + removing, updating := c.removeAndUpdateSimilarQueue(queue, queueList) + + g.Expect(len(queueList.Items)).To(Equal(2)) + g.Expect(len(removing)).To(Equal(2)) + g.Expect(len(updating)).To(Equal(1)) + g.Expect(len(updating[0].Spec.Components)).To(Equal(1)) + }) + + It("should skip same component version", func() { + + g := NewWithT(GinkgoT()) + + c := controller{} + name := "alpine" + + queue := &v1beta1.Queue{ + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.4"}}, }, - { - Spec: v1beta1.QueueSpec{Name: "ubuntu", Repository: "ubuntu", Version: "18.04"}, - Status: v1beta1.QueueStatus{}, + Status: v1beta1.QueueStatus{}, + } + queueList := &v1beta1.QueueList{ + Items: []v1beta1.Queue{ + { + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.4"}}, + }, + Status: v1beta1.QueueStatus{}, + }, }, - }, - } + } + + removing, updating := c.removeAndUpdateSimilarQueue(queue, queueList) - removing := c.removeSimilarExceptBundle(queue, queueList) + g.Expect(len(queueList.Items)).To(Equal(1)) + g.Expect(len(removing)).To(Equal(0)) + g.Expect(len(updating)).To(Equal(0)) + }) + }) - g.Expect(len(queueList.Items)).To(Equal(1)) - g.Expect(len(removing)).To(Equal(2)) + Describe("Add component into existing bundle Queue", func() { + It("should add component into existing bundle Queue", func() { + + g := NewWithT(GinkgoT()) + + c := controller{} + name := "alpine" + + queue := &v1beta1.Queue{ + Spec: v1beta1.QueueSpec{Name: "group", Bundle: "group", + Components: v1beta1.QueueComponents{{Name: "ubuntu", Repository: name, Version: "3.9.4"}}, + }, + Status: v1beta1.QueueStatus{}, + } + queueList := &v1beta1.QueueList{ + Items: []v1beta1.Queue{ + { + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.0"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + { + Spec: v1beta1.QueueSpec{Name: name, Bundle: "group", + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.1"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + }, + } + + updating := c.addExistingBundleQueue(queue, queueList) + + g.Expect(len(queueList.Items)).To(Equal(2)) + g.Expect(len(updating)).To(Equal(1)) + g.Expect(len(updating[0].Spec.Components)).To(Equal(2)) + }) + + It("should skip same component version", func() { + + g := NewWithT(GinkgoT()) + + c := controller{} + name := "alpine" + + queue := &v1beta1.Queue{ + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.4"}}, + }, + Status: v1beta1.QueueStatus{}, + } + queueList := &v1beta1.QueueList{ + Items: []v1beta1.Queue{ + { + Spec: v1beta1.QueueSpec{Name: name, + Components: v1beta1.QueueComponents{{Name: name, Repository: name, Version: "3.9.4"}}, + }, + Status: v1beta1.QueueStatus{}, + }, + }, + } + + updating := c.addExistingBundleQueue(queue, queueList) + + g.Expect(len(queueList.Items)).To(Equal(1)) + g.Expect(len(updating)).To(Equal(0)) + }) }) Describe("Reset Queue order", func() { - It("Should reset order of all Queues correctly", func() { + It("should reset order of all Queues correctly", func() { g := NewWithT(GinkgoT()) c := controller{} diff --git a/internal/reporter/msteams/reporter_test.go b/internal/reporter/msteams/reporter_test.go index 85aa46b4..ae268e9a 100644 --- a/internal/reporter/msteams/reporter_test.go +++ b/internal/reporter/msteams/reporter_test.go @@ -30,9 +30,14 @@ var _ = Describe("send ms teams message", func() { g.Expect(configCtrl).ShouldNot(BeNil()) rpcComp := &rpc.ComponentUpgrade{ - Name: "comp1", - Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, - Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + Name: "comp1", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + }, TeamName: "owner", IssueType: rpc.ComponentUpgrade_IssueType_DESIRED_VERSION_FAILED, Namespace: "owner-staging", @@ -113,9 +118,14 @@ var _ = Describe("send ms teams message", func() { g.Expect(configCtrl).ShouldNot(BeNil()) rpcComp := &rpc.ComponentUpgrade{ - Name: "comp1", - Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, - Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + Name: "comp1", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + }, TeamName: "owner", IssueType: rpc.ComponentUpgrade_IssueType_IMAGE_MISSING, Namespace: "owner-staging", @@ -142,6 +152,40 @@ var _ = Describe("send ms teams message", func() { g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("image-2:1.1.0")) g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("image-3:1.2.0")) }) + + It("should send component upgrade failure of multiple components", func() { + configCtrl := newMockConfigCtrl("", s2hv1beta1.IntervalEveryTime, "") + g.Expect(configCtrl).ShouldNot(BeNil()) + + rpcComp := &rpc.ComponentUpgrade{ + Name: "group", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + { + Name: "comp2", + Image: &rpc.Image{Repository: "image-2", Tag: "1.1.2"}, + }, + }, + } + mockMSTeamsCli := &mockMSTeams{} + r := s2hmsteams.New("tenantID", "clientID", "clientSecret", "user", + "pass", s2hmsteams.WithMSTeamsClient(mockMSTeamsCli)) + comp := internal.NewComponentUpgradeReporter(rpcComp, internal.SamsahaiConfig{}) + err := r.SendComponentUpgrade(configCtrl, comp) + g.Expect(err).Should(BeNil()) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("Failure")) + // Should contain information + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("comp1")) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("1.1.0")) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("image-1")) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("comp2")) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("1.1.2")) + g.Expect(mockMSTeamsCli.message).Should(ContainSubstring("image-2")) + }) }) Describe("send active promotion", func() { @@ -507,6 +551,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/reporter/rest/reporter_test.go b/internal/reporter/rest/reporter_test.go index b9989ef6..64f45459 100644 --- a/internal/reporter/rest/reporter_test.go +++ b/internal/reporter/rest/reporter_test.go @@ -94,11 +94,21 @@ var _ = Describe("send rest message", func() { }) It("should correctly send component upgrade", func() { - img := &rpc.Image{Repository: "image-1", Tag: "1.1.0"} + img1 := &rpc.Image{Repository: "image-1", Tag: "1.1.0"} + img2 := &rpc.Image{Repository: "image-2", Tag: "1.1.2"} rpcComp := &rpc.ComponentUpgrade{ - Name: "comp1", - Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, - Image: img, + Name: "group", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: img1, + }, + { + Name: "comp2", + Image: img2, + }, + }, TeamName: "owner", IssueType: rpc.ComponentUpgrade_IssueType_IMAGE_MISSING, Namespace: "owner-staging", @@ -125,14 +135,22 @@ var _ = Describe("send rest message", func() { "testBuildTypeID should be matched") g.Expect(gjson.GetBytes(body, "testRunner.teamcity.buildURL").String()).To(BeEmpty(), "teamcityURL should be empty") - g.Expect(gjson.GetBytes(body, "image.repository").String()).To(Equal(img.Repository), - "imageRepository should be matched") - g.Expect(gjson.GetBytes(body, "image.tag").String()).To(Equal(img.Tag), - "imageTag should be matched") g.Expect(gjson.GetBytes(body, "namespace").String()).To(Equal(rpcComp.Namespace), "namespace should be matched") g.Expect(gjson.GetBytes(body, "isReverify").String()).To(Equal("true"), "isReverify should be matched") + + components := gjson.GetBytes(body, "components").Array() + g.Expect(len(components)).To(Equal(2)) + g.Expect(gjson.GetBytes([]byte(components[0].String()), "image.repository").String()).To(Equal(img1.Repository), + "imageRepository should be matched") + g.Expect(gjson.GetBytes([]byte(components[0].String()), "image.tag").String()).To(Equal(img1.Tag), + "imageTag should be matched") + g.Expect(gjson.GetBytes([]byte(components[1].String()), "image.repository").String()).To(Equal(img2.Repository), + "imageRepository should be matched") + g.Expect(gjson.GetBytes([]byte(components[1].String()), "image.tag").String()).To(Equal(img2.Tag), + "imageTag should be matched") + }) defer server.Close() @@ -254,6 +272,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/reporter/shell/reporter_test.go b/internal/reporter/shell/reporter_test.go index 5f748818..f6bc7f79 100644 --- a/internal/reporter/shell/reporter_test.go +++ b/internal/reporter/shell/reporter_test.go @@ -203,6 +203,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/reporter/slack/reporter_test.go b/internal/reporter/slack/reporter_test.go index c8a65644..cc071097 100644 --- a/internal/reporter/slack/reporter_test.go +++ b/internal/reporter/slack/reporter_test.go @@ -30,9 +30,14 @@ var _ = Describe("send slack message", func() { g.Expect(configCtrl).ShouldNot(BeNil()) rpcComp := &rpc.ComponentUpgrade{ - Name: "comp1", - Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, - Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + Name: "comp1", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + }, TeamName: "owner", IssueType: rpc.ComponentUpgrade_IssueType_DESIRED_VERSION_FAILED, Namespace: "owner-staging", @@ -106,9 +111,14 @@ var _ = Describe("send slack message", func() { g.Expect(configCtrl).ShouldNot(BeNil()) rpcComp := &rpc.ComponentUpgrade{ - Name: "comp1", - Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, - Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + Name: "comp1", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + }, TeamName: "owner", IssueType: rpc.ComponentUpgrade_IssueType_IMAGE_MISSING, Namespace: "owner-staging", @@ -131,6 +141,39 @@ var _ = Describe("send slack message", func() { g.Expect(mockSlackCli.message).Should(ContainSubstring("- image-2:1.1.0")) g.Expect(mockSlackCli.message).Should(ContainSubstring("- image-3:1.2.0")) }) + + It("should send component upgrade failure of multiple components", func() { + configCtrl := newMockConfigCtrl("", s2hv1beta1.IntervalEveryTime, "") + g.Expect(configCtrl).ShouldNot(BeNil()) + + rpcComp := &rpc.ComponentUpgrade{ + Name: "group", + Status: rpc.ComponentUpgrade_UpgradeStatus_FAILURE, + Components: []*rpc.Component{ + { + Name: "comp1", + Image: &rpc.Image{Repository: "image-1", Tag: "1.1.0"}, + }, + { + Name: "comp2", + Image: &rpc.Image{Repository: "image-2", Tag: "1.1.2"}, + }, + }, + } + mockSlackCli := &mockSlack{} + r := s2hslack.New("mock-token", s2hslack.WithSlackClient(mockSlackCli)) + comp := internal.NewComponentUpgradeReporter(rpcComp, internal.SamsahaiConfig{}) + err := r.SendComponentUpgrade(configCtrl, comp) + g.Expect(err).Should(BeNil()) + g.Expect(mockSlackCli.message).Should(ContainSubstring("Failure")) + // Should contain information + g.Expect(mockSlackCli.message).Should(ContainSubstring("comp1")) + g.Expect(mockSlackCli.message).Should(ContainSubstring("1.1.0")) + g.Expect(mockSlackCli.message).Should(ContainSubstring("image-1")) + g.Expect(mockSlackCli.message).Should(ContainSubstring("comp2")) + g.Expect(mockSlackCli.message).Should(ContainSubstring("1.1.2")) + g.Expect(mockSlackCli.message).Should(ContainSubstring("image-2")) + }) }) Describe("send active promotion", func() { @@ -425,6 +468,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/samsahai/checker/harbor/checker_test.go b/internal/samsahai/checker/harbor/checker_test.go index 6b65aff4..89728863 100644 --- a/internal/samsahai/checker/harbor/checker_test.go +++ b/internal/samsahai/checker/harbor/checker_test.go @@ -36,11 +36,11 @@ var _ = Describe("Harbor Checker", func() { }) - It("Should returns 'harbor' as name", func() { + It("should returns 'harbor' as name", func() { Expect(checker.GetName()).To(Equal("harbor")) }) - It("Should successfully get new version from harbor", func(done Done) { + It("should successfully get new version from harbor", func(done Done) { defer close(done) server = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -570,7 +570,7 @@ var _ = Describe("Harbor Checker", func() { g.Expect(version).To(Equal("1.13.5-3.0.0-beta.2")) }) - It("Should correctly ensure version", func(done Done) { + It("should correctly ensure version", func(done Done) { defer close(done) server = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() diff --git a/internal/samsahai/checker/publicregistry/checker_test.go b/internal/samsahai/checker/publicregistry/checker_test.go index a322c0e5..7f6f0dad 100644 --- a/internal/samsahai/checker/publicregistry/checker_test.go +++ b/internal/samsahai/checker/publicregistry/checker_test.go @@ -65,7 +65,7 @@ var _ = Describe("Public Registry Checker", func() { Expect(err).NotTo(BeNil()) }) - It("Should correctly ensure version", func(done Done) { + It("should correctly ensure version", func(done Done) { defer close(done) err := checker.EnsureVersion("phantomnat/curl", "curl", "3.9.1") diff --git a/internal/samsahai/checker/samsahai/check_test.go b/internal/samsahai/checker/samsahai/check_test.go index 89e0c8a1..3be2f00e 100644 --- a/internal/samsahai/checker/samsahai/check_test.go +++ b/internal/samsahai/checker/samsahai/check_test.go @@ -117,11 +117,11 @@ var _ = Describe("", func() { _ = crClient.Delete(ctx, team) }, timeoutSec) - It("Should return checker name", func() { + It("should return checker name", func() { Expect(check.GetName()).To(Equal(CheckerName)) }) - It("Should successfully get version", func() { + It("should successfully get version", func() { version, err := check.GetVersion("", "mariadb", "") Expect(err).NotTo(HaveOccurred()) Expect(version).To(Equal("12.0.0-r0")) @@ -135,17 +135,17 @@ var _ = Describe("", func() { }) Describe("Bad path", func() { - It("Should error when repository not matched", func() { + It("should error when repository not matched", func() { _, err := check.GetVersion("mariadb", "mariadb", "") Expect(err).To(HaveOccurred()) }) - It("Should error when team not matched", func() { + It("should error when team not matched", func() { _, err := check.GetVersion("", "mariadb", "should-not-exist") Expect(err).To(HaveOccurred()) }) - It("Should error when pattern is invalid", func() { + It("should error when pattern is invalid", func() { _, err := check.GetVersion("", "mariadb", "((") Expect(err).To(HaveOccurred()) }) diff --git a/internal/samsahai/exporter/metric_test.go b/internal/samsahai/exporter/metric_test.go index 866e8238..8367235a 100644 --- a/internal/samsahai/exporter/metric_test.go +++ b/internal/samsahai/exporter/metric_test.go @@ -91,12 +91,21 @@ var _ = Describe("Samsahai Exporter", func() { } queue := &s2hv1beta1.Queue{ ObjectMeta: metav1.ObjectMeta{ - Name: "qName1", + Name: "group", Namespace: namespace, }, Spec: s2hv1beta1.QueueSpec{ - TeamName: "testQTeamName1", - Version: "10.9.8.7", + TeamName: "testQTeamName1", + Components: s2hv1beta1.QueueComponents{ + { + Name: "qName1", + Version: "10.9.8.7", + }, + { + Name: "qName2", + Version: "10.9.8.7.2", + }, + }, NoOfOrder: 0, }, Status: s2hv1beta1.QueueStatus{ @@ -133,24 +142,26 @@ var _ = Describe("Samsahai Exporter", func() { wgStop.Wait() }, timeout) - It("Should show team name correctly ", func() { + It("should show team name correctly ", func() { _, data, err := http.Get("http://localhost:8008/metrics") g.Expect(err).NotTo(HaveOccurred()) expectedData := strings.Contains(string(data), `samsahai_team{teamName="testQTeamName1"} 1`) g.Expect(expectedData).To(BeTrue()) }, timeout) - It("Should show queue metric correctly ", func(done Done) { + It("should show queue metric correctly ", func(done Done) { defer close(done) _, data, err := http.Get("http://localhost:8008/metrics") g.Expect(err).NotTo(HaveOccurred()) - expectedData := strings.Contains(string(data), `samsahai_queue{component="qName1",no_of_processed="1",order="0",state="waiting",teamName="testQTeamName1",version="10.9.8.7"} 1`) + expectedData := strings.Contains(string(data), `samsahai_queue{component="qName1",no_of_processed="1",order="0",queueName="group",state="waiting",teamName="testQTeamName1",version="10.9.8.7"} 1`) + g.Expect(expectedData).To(BeTrue()) + expectedData = strings.Contains(string(data), `samsahai_queue{component="qName2",no_of_processed="1",order="0",queueName="group",state="waiting",teamName="testQTeamName1",version="10.9.8.7.2"} 1`) g.Expect(expectedData).To(BeTrue()) expectedData = strings.Contains(string(data), `samsahai_queue{component="",`) g.Expect(expectedData).To(BeFalse()) }, timeout) - It("Should show active promotion correctly", func(done Done) { + It("should show active promotion correctly", func(done Done) { defer close(done) _, data, err := http.Get("http://localhost:8008/metrics") g.Expect(err).NotTo(HaveOccurred()) @@ -158,7 +169,7 @@ var _ = Describe("Samsahai Exporter", func() { g.Expect(expectedData).To(BeTrue()) }, timeout) - It("Should show health metric correctly", func(done Done) { + It("should show health metric correctly", func(done Done) { defer close(done) _, data, err := http.Get("http://localhost:8008/metrics") g.Expect(err).NotTo(HaveOccurred()) @@ -273,6 +284,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/samsahai/internal_process.go b/internal/samsahai/internal_process.go index 3f75db75..db6cd840 100644 --- a/internal/samsahai/internal_process.go +++ b/internal/samsahai/internal_process.go @@ -135,7 +135,6 @@ func (c *controller) checkComponentChanged(component changedComponent) error { return nil } -// TODO: pohfy, check bundle changed func (c *controller) checkTeamComponentChanged(compName, repository, teamName string) error { configCtrl := c.GetConfigController() team := &s2hv1beta1.Team{} diff --git a/internal/samsahai/plugin/plugin_test.go b/internal/samsahai/plugin/plugin_test.go index 488fe6e2..d600829b 100644 --- a/internal/samsahai/plugin/plugin_test.go +++ b/internal/samsahai/plugin/plugin_test.go @@ -20,7 +20,7 @@ var _ = Describe("Plugin", func() { pluginName := "example" - It("Should successfully load and verify plugin", func() { + It("should successfully load and verify plugin", func() { plugin, err := New("./example-shell.sh") g.Expect(err).NotTo(HaveOccurred()) g.Expect(plugin).NotTo(BeNil()) @@ -36,7 +36,7 @@ var _ = Describe("Plugin", func() { }) Describe("get-version", func() { - It("Should correctly get version", func() { + It("should correctly get version", func() { plugin, err := New("./example-shell.sh") g.Expect(err).NotTo(HaveOccurred()) g.Expect(plugin).NotTo(BeNil()) diff --git a/internal/samsahai/rpc.go b/internal/samsahai/rpc.go index 7c7f56ec..07425803 100644 --- a/internal/samsahai/rpc.go +++ b/internal/samsahai/rpc.go @@ -219,12 +219,11 @@ func (c *controller) SendUpdateStateQueueMetric(ctx context.Context, comp *rpc.C return nil, err } - compName := comp.GetName() - if compName != "" { + queueName := comp.GetName() + if queueName != "" { queue := &s2hv1beta1.Queue{} - if err := c.client.Get(context.TODO(), types.NamespacedName{ - Namespace: comp.GetNamespace(), - Name: compName}, queue); err != nil { + err := c.client.Get(context.TODO(), types.NamespacedName{Namespace: comp.GetNamespace(), Name: queueName}, queue) + if err != nil { logger.Error(err, "cannot get the queue") } exporter.SetQueueMetric(queue) diff --git a/internal/samsahai/webhook/webhook_test.go b/internal/samsahai/webhook/webhook_test.go index deab2395..9b11553c 100644 --- a/internal/samsahai/webhook/webhook_test.go +++ b/internal/samsahai/webhook/webhook_test.go @@ -145,7 +145,7 @@ var _ = Describe("Samsahai Webhook", func() { server.Close() }, timeout) - It("Should successfully get version", func(done Done) { + It("should successfully get version", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + s2h.URIVersion) g.Expect(err).NotTo(HaveOccurred()) @@ -153,7 +153,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(gjson.ValidBytes(data)).To(BeTrue()) }, timeout) - It("Should successfully get health check", func(done Done) { + It("should successfully get health check", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + s2h.URIHealthz) g.Expect(err).NotTo(HaveOccurred()) @@ -162,7 +162,7 @@ var _ = Describe("Samsahai Webhook", func() { }, timeout) Describe("Plugin", func() { - It("Should successfully receive webhook from plugin", func(done Done) { + It("should successfully receive webhook from plugin", func(done Done) { defer close(done) pluginName := "example" @@ -178,7 +178,7 @@ var _ = Describe("Samsahai Webhook", func() { }) Describe("Team", func() { - It("Should successfully list teams", func(done Done) { + It("should successfully list teams", func(done Done) { defer close(done) defer GinkgoRecover() @@ -187,7 +187,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get team", func(done Done) { + It("should successfully get team", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName) @@ -202,7 +202,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(err).To(HaveOccurred()) }, timeout) - It("Should successfully get team configuration", func(done Done) { + It("should successfully get team configuration", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/config") @@ -210,7 +210,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get team component", func(done Done) { + It("should successfully get team component", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/components") @@ -218,7 +218,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get stable values from team", func(done Done) { + It("should successfully get stable values from team", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/components/redis/values") @@ -226,7 +226,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get zip log from queue history", func(done Done) { + It("should successfully get zip log from queue history", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/queue/histories/test-history/log") @@ -234,7 +234,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get zip log from active promotion history", func(done Done) { + It("should successfully get zip log from active promotion history", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/activepromotions/histories/activepromotion-history/log") @@ -244,7 +244,7 @@ var _ = Describe("Samsahai Webhook", func() { }) Describe("ActivePromotion", func() { - It("Should successfully list activepromotions", func(done Done) { + It("should successfully list activepromotions", func(done Done) { defer close(done) defer GinkgoRecover() @@ -253,7 +253,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get team activepromotion", func(done Done) { + It("should successfully get team activepromotion", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/activepromotions") @@ -261,7 +261,7 @@ var _ = Describe("Samsahai Webhook", func() { g.Expect(data).NotTo(BeNil()) }, timeout) - It("Should successfully get team activepromotion histories", func(done Done) { + It("should successfully get team activepromotion histories", func(done Done) { defer close(done) _, data, err := http.Get(server.URL + "/teams/" + teamName + "/activepromotions/histories") @@ -391,6 +391,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return comps, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/staging/controller_test.go b/internal/staging/controller_test.go index 8158b125..89bc7ba0 100644 --- a/internal/staging/controller_test.go +++ b/internal/staging/controller_test.go @@ -31,7 +31,7 @@ var _ = Describe("Apply Env Based Config", func() { g.Expect(err).NotTo(HaveOccurred()) }) - It("Should successfully apply configuration based on queue type", func() { + It("should successfully apply configuration based on queue type", func() { config, err := configCtrl.Get("mock") g.Expect(err).NotTo(HaveOccurred()) @@ -80,7 +80,7 @@ var _ = Describe("Apply Env Based Config", func() { } }) - It("Should correctly combine base values and config", func() { + It("should correctly combine base values and config", func() { config, err := configCtrl.Get("mock") g.Expect(err).NotTo(HaveOccurred()) @@ -228,6 +228,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return comps, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/internal/util/dotaccess/dotaccess_test.go b/internal/util/dotaccess/dotaccess_test.go index 0d4dd685..795e0d6c 100644 --- a/internal/util/dotaccess/dotaccess_test.go +++ b/internal/util/dotaccess/dotaccess_test.go @@ -17,7 +17,7 @@ func TestUnit(t *testing.T) { var _ = Describe("Dot Access", func() { g := NewWithT(GinkgoT()) - It("Should successfully access map[string]interface{} by dot", func() { + It("should successfully access map[string]interface{} by dot", func() { o := map[string]interface{}{ "t": map[string]interface{}{ "1": 1, diff --git a/internal/util/map_test.go b/internal/util/map_test.go index caf40f98..02cbb2be 100644 --- a/internal/util/map_test.go +++ b/internal/util/map_test.go @@ -16,7 +16,7 @@ func TestCopyMap(t *testing.T) { var _ = Describe("Copy Map", func() { g := NewWithT(GinkgoT()) - It("Should successfully copy map of string of interface{}", func() { + It("should successfully copy map of string of interface{}", func() { m1 := map[string]interface{}{ "a": "bbb", "b": map[string]interface{}{ diff --git a/internal/util/msteams/msteams_test.go b/internal/util/msteams/msteams_test.go index eecb5f1c..cc2e08c3 100644 --- a/internal/util/msteams/msteams_test.go +++ b/internal/util/msteams/msteams_test.go @@ -31,7 +31,7 @@ var _ = Describe("Microsoft Teams", func() { pass = "pass" ) - It("Should successfully get access token from Microsoft Graph API", func(done Done) { + It("should successfully get access token from Microsoft Graph API", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -57,7 +57,7 @@ var _ = Describe("Microsoft Teams", func() { g.Expect(accessToken).To(Equal("token-123456")) }) - It("Should successfully post message with Microsoft Graph API", func(done Done) { + It("should successfully post message with Microsoft Graph API", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -109,7 +109,7 @@ var _ = Describe("Microsoft Teams", func() { }) Describe("GetGroupID", func() { - It("Should successfully get group id from given group id", func(done Done) { + It("should successfully get group id from given group id", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -127,7 +127,7 @@ var _ = Describe("Microsoft Teams", func() { g.Expect(groupID).To(Equal("52f44e9b-5cf2-4b77-a6d3-b81e49b7a45c")) }) - It("Should successfully get group id from given group name", func(done Done) { + It("should successfully get group id from given group name", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -184,7 +184,7 @@ var _ = Describe("Microsoft Teams", func() { g.Expect(groupID).To(Equal("52f44e9b-5cf2-4b77-a6d3-b81e49xxxxxx")) }) - It("Should not get group id due to not found", func(done Done) { + It("should not get group id due to not found", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -242,7 +242,7 @@ var _ = Describe("Microsoft Teams", func() { }) Describe("GetChannelID", func() { - It("Should successfully get channel id from given channel id", func(done Done) { + It("should successfully get channel id from given channel id", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() @@ -271,7 +271,7 @@ var _ = Describe("Microsoft Teams", func() { g.Expect(channelD).To(Equal("channelID")) }) - It("Should successfully get channel id from given channel name", func(done Done) { + It("should successfully get channel id from given channel name", func(done Done) { defer close(done) server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer GinkgoRecover() diff --git a/internal/util/protostruct/unit_test.go b/internal/util/protostruct/unit_test.go index 89fd5a8f..18e09d32 100644 --- a/internal/util/protostruct/unit_test.go +++ b/internal/util/protostruct/unit_test.go @@ -57,7 +57,7 @@ var ( } ) var _ = Describe("Protobuf Struct to map", func() { - It("Should successfully Encode/Decode", func() { + It("should successfully Encode/Decode", func() { g := NewWithT(GinkgoT()) var pbstsruct *pb.Struct = nil diff --git a/test/e2e/queue/ctrl.go b/test/e2e/queue/ctrl.go index 658c4561..1e338fcb 100644 --- a/test/e2e/queue/ctrl.go +++ b/test/e2e/queue/ctrl.go @@ -57,7 +57,7 @@ var _ = Describe("[e2e] Queue controller", func() { first, err := controller.First() Expect(err).To(BeNil()) - Expect(first.IsSame(q)).To(BeTrue()) + Expect(first.IsSameComponent(q)).To(BeTrue()) err = controller.Remove(first) Expect(err).To(BeNil()) @@ -92,7 +92,7 @@ var _ = Describe("[e2e] Queue controller", func() { first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSame(alpine390)).To(BeTrue()) + Expect(first.IsSameComponent(alpine390)).To(BeTrue()) By("Adding alpine 3.9.1") @@ -100,7 +100,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSame(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") + Expect(first.IsSameComponent(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") size = controller.Size() Expect(size).To(Equal(3), "size of queue should remain 3") @@ -110,7 +110,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSame(alpine392)).To(BeTrue(), "alpine 3.9.2 should be on top of queue") + Expect(first.IsSameComponent(alpine392)).To(BeTrue(), "alpine 3.9.2 should be on top of queue") size = controller.Size() Expect(size).To(Equal(3), "size of queue should remain 3") @@ -120,7 +120,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSame(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") + Expect(first.IsSameComponent(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") By("Removing all queues") From 4c0821c83584d33da638a12249bb4f0da60c504e Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 17:28:07 +0700 Subject: [PATCH 09/12] :white_check_mark: Update e2e test --- api/v1beta1/queue_types.go | 2 +- internal/queue/controller.go | 24 +-- internal/reporter.go | 4 +- internal/reporter/rest/reporter.go | 12 +- .../samsahai/checker/samsahai/check_test.go | 4 + test/data/wordpress-redis/config.yaml | 4 + test/e2e/config/ctrl.go | 7 + test/e2e/queue/ctrl.go | 181 ++++++++++++++++-- test/e2e/samsahai/ctrl.go | 12 +- test/e2e/staging/ctrl.go | 9 +- 10 files changed, 220 insertions(+), 39 deletions(-) diff --git a/api/v1beta1/queue_types.go b/api/v1beta1/queue_types.go index 191cb556..8af46041 100644 --- a/api/v1beta1/queue_types.go +++ b/api/v1beta1/queue_types.go @@ -281,7 +281,7 @@ type Queue struct { Status QueueStatus `json:"status,omitempty"` } -func (q *Queue) IsSameComponent(dName string, dComp *QueueComponent) bool { +func (q *Queue) ContainSameComponent(dName string, dComp *QueueComponent) bool { if dName != q.Spec.Name { return false } diff --git a/internal/queue/controller.go b/internal/queue/controller.go index 0b22342a..e7129d80 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -129,12 +129,11 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo return nil } - //bundleQueue := &s2hv1beta1.Queue{} pQueue := &s2hv1beta1.Queue{} isAlreadyInQueue := false isAlreadyInBundle := false for i, q := range queueList.Items { - if q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { + if q.ContainSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { isAlreadyInQueue = true pQueue = &queueList.Items[i] break @@ -157,6 +156,7 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo if err := c.client.Update(ctx, &updatingList[i]); err != nil { return err } + queueList.Items[i] = updatingList[i] } updatingList = c.addExistingBundleQueue(queue, queueList) @@ -169,6 +169,7 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo if err := c.client.Update(ctx, &updatingList[i]); err != nil { return err } + queueList.Items[i] = updatingList[i] } queueList.Sort() @@ -177,7 +178,7 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo if isAlreadyInQueue { var isQueueOnTop bool if len(queueList.Items[0].Spec.Components) > 0 { - isQueueOnTop = pQueue.IsSameComponent(queueList.Items[0].Spec.Name, queueList.Items[0].Spec.Components[0]) + isQueueOnTop = pQueue.ContainSameComponent(queueList.Items[0].Spec.Name, queueList.Items[0].Spec.Components[0]) } // move queue to the top @@ -193,9 +194,10 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo // queue not exist if atTop { queue.Spec.NoOfOrder = queueList.TopQueueOrder() + } else { + queue.Spec.NoOfOrder = queueList.LastQueueOrder() } - queue.Spec.NoOfOrder = queueList.LastQueueOrder() queue.Status.State = s2hv1beta1.Waiting queue.Status.CreatedAt = &now queue.Status.UpdatedAt = &now @@ -239,11 +241,11 @@ func (c *controller) addExistingBundleQueue(queue *s2hv1beta1.Queue, list *s2hv1 var items []s2hv1beta1.Queue var updating []s2hv1beta1.Queue - var hasSameQueue = false + var containComp = false for _, q := range list.Items { - if !hasSameQueue && q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { + if !containComp && q.ContainSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { // only add one `queue` to items - hasSameQueue = true + containComp = true // update component of bundle } else if q.Spec.Bundle == queue.Spec.Bundle { var found bool @@ -276,14 +278,12 @@ func (c *controller) removeAndUpdateSimilarQueue(queue *s2hv1beta1.Queue, list * removing []s2hv1beta1.Queue, updating []s2hv1beta1.Queue) { var items []s2hv1beta1.Queue - var hasSameQueue = false + var containComp = false for _, q := range list.Items { - // if existing queue is bundle queue, these queues will not be the same since - // `queue` always contains 1 component - if !hasSameQueue && q.IsSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { + if !containComp && q.ContainSameComponent(queue.Spec.Name, queue.Spec.Components[0]) { // only add one `queue` to items - hasSameQueue = true + containComp = true } else { newComps := make([]*s2hv1beta1.QueueComponent, 0) for _, qComp := range q.Spec.Components { diff --git a/internal/reporter.go b/internal/reporter.go index 935ff78e..409b6c99 100644 --- a/internal/reporter.go +++ b/internal/reporter.go @@ -45,14 +45,14 @@ type ComponentUpgradeReporter struct { Credential s2hv1beta1.Credential `json:"credential,omitempty"` Envs map[string]string - rpc.ComponentUpgrade + *rpc.ComponentUpgrade SamsahaiConfig } // NewComponentUpgradeReporter creates component upgrade reporter from rpc object func NewComponentUpgradeReporter(comp *rpc.ComponentUpgrade, s2hConfig SamsahaiConfig, opts ...ComponentUpgradeOption) *ComponentUpgradeReporter { c := &ComponentUpgradeReporter{ - ComponentUpgrade: *comp, + ComponentUpgrade: comp, SamsahaiConfig: s2hConfig, IssueTypeStr: convertIssueType(comp.IssueType), StatusStr: convertStatusType(comp.Status), diff --git a/internal/reporter/rest/reporter.go b/internal/reporter/rest/reporter.go index 6537aa13..9e9695df 100644 --- a/internal/reporter/rest/reporter.go +++ b/internal/reporter/rest/reporter.go @@ -32,17 +32,17 @@ type ReporterJSON struct { type componentUpgradeRest struct { ReporterJSON - internal.ComponentUpgradeReporter + *internal.ComponentUpgradeReporter } type activePromotionRest struct { ReporterJSON - internal.ActivePromotionReporter + *internal.ActivePromotionReporter } type imageMissingRest struct { ReporterJSON - rpc.Image + *rpc.Image } // NewReporterJSON creates new reporter json @@ -103,7 +103,7 @@ func (r *reporter) SendComponentUpgrade(configCtrl internal.ConfigController, co } for _, ep := range config.Spec.Reporter.Rest.ComponentUpgrade.Endpoints { - restObj := &componentUpgradeRest{NewReporterJSON(), *comp} + restObj := &componentUpgradeRest{NewReporterJSON(), comp} body, err := json.Marshal(restObj) if err != nil { logger.Error(err, fmt.Sprintf("cannot convert struct to json object, %v", body)) @@ -132,7 +132,7 @@ func (r *reporter) SendActivePromotionStatus(configCtrl internal.ConfigControlle } for _, ep := range config.Spec.Reporter.Rest.ActivePromotion.Endpoints { - restObj := &activePromotionRest{NewReporterJSON(), *atpRpt} + restObj := &activePromotionRest{NewReporterJSON(), atpRpt} body, err := json.Marshal(restObj) if err != nil { logger.Error(err, fmt.Sprintf("cannot convert struct to json object, %v", body)) @@ -161,7 +161,7 @@ func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigC } for _, ep := range config.Spec.Reporter.Rest.ImageMissing.Endpoints { - restObj := &imageMissingRest{NewReporterJSON(), *img} + restObj := &imageMissingRest{NewReporterJSON(), img} body, err := json.Marshal(restObj) if err != nil { logger.Error(err, fmt.Sprintf("cannot convert struct to json object, %v", body)) diff --git a/internal/samsahai/checker/samsahai/check_test.go b/internal/samsahai/checker/samsahai/check_test.go index 3be2f00e..40ca3ff6 100644 --- a/internal/samsahai/checker/samsahai/check_test.go +++ b/internal/samsahai/checker/samsahai/check_test.go @@ -259,6 +259,10 @@ func (c *mockConfigCtrl) GetParentComponents(configName string) (map[string]*s2h return map[string]*s2hv1beta1.Component{}, nil } +func (c *mockConfigCtrl) GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) { + return s2hv1beta1.ConfigBundles{}, nil +} + func (c *mockConfigCtrl) Update(config *s2hv1beta1.Config) error { return nil } diff --git a/test/data/wordpress-redis/config.yaml b/test/data/wordpress-redis/config.yaml index a8909dea..4da84c24 100644 --- a/test/data/wordpress-redis/config.yaml +++ b/test/data/wordpress-redis/config.yaml @@ -38,6 +38,10 @@ spec: pollingTime: 5s testMock: result: true + bundles: + db: + - redis + - mariadb components: - name: redis chart: diff --git a/test/e2e/config/ctrl.go b/test/e2e/config/ctrl.go index c287309a..ed62651e 100644 --- a/test/e2e/config/ctrl.go +++ b/test/e2e/config/ctrl.go @@ -82,6 +82,13 @@ var _ = Describe("[e2e] Config controller", func() { Expect(err).To(BeNil()) Expect(len(parentComps)).To(Equal(2)) + By("Get bundles") + bundles, err := controller.GetBundles(teamName) + Expect(err).To(BeNil()) + dbs, ok := bundles["db"] + Expect(ok).To(BeTrue()) + Expect(len(dbs)).To(Equal(2)) + By("Delete Config") err = controller.Delete(teamName) diff --git a/test/e2e/queue/ctrl.go b/test/e2e/queue/ctrl.go index 1e338fcb..9fe8ac7d 100644 --- a/test/e2e/queue/ctrl.go +++ b/test/e2e/queue/ctrl.go @@ -9,7 +9,7 @@ import ( rclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" - "github.com/agoda-com/samsahai/api/v1beta1" + s2hv1beta1 "github.com/agoda-com/samsahai/api/v1beta1" "github.com/agoda-com/samsahai/internal" "github.com/agoda-com/samsahai/internal/queue" ) @@ -47,7 +47,9 @@ var _ = Describe("[e2e] Queue controller", func() { It("should successfully create/get/delete Queue", func(done Done) { defer close(done) - q := queue.NewUpgradeQueue(teamName, namespace, "alpine", "alpine", "3.9.3") + q := queue.NewUpgradeQueue(teamName, namespace, "alpine", "", + s2hv1beta1.QueueComponents{{Name: "alpine", Version: "3.9.3"}}, + ) var err = controller.Add(q) Expect(err).To(BeNil()) @@ -57,7 +59,7 @@ var _ = Describe("[e2e] Queue controller", func() { first, err := controller.First() Expect(err).To(BeNil()) - Expect(first.IsSameComponent(q)).To(BeTrue()) + Expect(first.ContainSameComponent(q.Name, q.Spec.Components[0])).To(BeTrue()) err = controller.Remove(first) Expect(err).To(BeNil()) @@ -70,11 +72,19 @@ var _ = Describe("[e2e] Queue controller", func() { defer close(done) var err error - var first *v1beta1.Queue - var alpine390 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "alpine", "3.9.0") - var alpine391 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "alpine", "3.9.1") - var alpine392 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "alpine", "3.9.2") - var ubuntu = queue.NewUpgradeQueue(teamName, namespace, "ubuntu", "ubuntu", "18.04") + var first *s2hv1beta1.Queue + var alpine390 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "", + s2hv1beta1.QueueComponents{{Name: "alpine", Version: "3.9.0"}}, + ) + var alpine391 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "", + s2hv1beta1.QueueComponents{{Name: "alpine", Version: "3.9.1"}}, + ) + var alpine392 = queue.NewUpgradeQueue(teamName, namespace, "alpine", "", + s2hv1beta1.QueueComponents{{Name: "alpine", Version: "3.9.2"}}, + ) + var ubuntu = queue.NewUpgradeQueue(teamName, namespace, "ubuntu", "", + s2hv1beta1.QueueComponents{{Name: "ubuntu", Version: "18.04"}}, + ) var size int Expect(controller.Size()).To(Equal(0), "should start with empty queue") @@ -85,14 +95,16 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) err = controller.Add(ubuntu) Expect(err).To(BeNil()) - err = controller.Add(queue.NewUpgradeQueue(teamName, namespace, "node", "node", "11.0.0")) + err = controller.Add(queue.NewUpgradeQueue(teamName, namespace, "node", "", + s2hv1beta1.QueueComponents{{Name: "node", Version: "11.0.0"}}, + )) Expect(err).To(BeNil()) size = controller.Size() Expect(size).To(Equal(3)) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSameComponent(alpine390)).To(BeTrue()) + Expect(first.ContainSameComponent(alpine390.Name, alpine390.Spec.Components[0])).To(BeTrue()) By("Adding alpine 3.9.1") @@ -100,7 +112,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSameComponent(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") + Expect(first.ContainSameComponent(ubuntu.Name, ubuntu.Spec.Components[0])).To(BeTrue(), "ubuntu should be on top of queue") size = controller.Size() Expect(size).To(Equal(3), "size of queue should remain 3") @@ -110,7 +122,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSameComponent(alpine392)).To(BeTrue(), "alpine 3.9.2 should be on top of queue") + Expect(first.ContainSameComponent(alpine392.Name, alpine392.Spec.Components[0])).To(BeTrue(), "alpine 3.9.2 should be on top of queue") size = controller.Size() Expect(size).To(Equal(3), "size of queue should remain 3") @@ -120,7 +132,150 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(err).To(BeNil()) first, err = controller.First() Expect(err).To(BeNil()) - Expect(first.IsSameComponent(ubuntu)).To(BeTrue(), "ubuntu should be on top of queue") + Expect(first.ContainSameComponent(ubuntu.Name, ubuntu.Spec.Components[0])).To(BeTrue(), "ubuntu should be on top of queue") + + By("Removing all queues") + + err = controller.RemoveAllQueues() + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(0)) + }, 3) + + It("should successfully update component to existing bundle", func(done Done) { + defer close(done) + + var err error + var first *s2hv1beta1.Queue + var alpine = queue.NewUpgradeQueue(teamName, namespace, "application", "application", + s2hv1beta1.QueueComponents{{Name: "alpine", Version: "3.9.0"}}, + ) + var ubuntu = queue.NewUpgradeQueue(teamName, namespace, "ubuntu", "", + s2hv1beta1.QueueComponents{{Name: "ubuntu", Version: "18.04"}}, + ) + var node = queue.NewUpgradeQueue(teamName, namespace, "application", "application", + s2hv1beta1.QueueComponents{{Name: "node", Version: "11.0.0"}}, + ) + var size int + + Expect(controller.Size()).To(Equal(0), "should start with empty queue") + + By("Create 2 queue") + + err = controller.Add(alpine) + Expect(err).To(BeNil()) + err = controller.Add(ubuntu) + Expect(err).To(BeNil()) + + By("Add node application") + + err = controller.Add(node) + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(2)) + + first, err = controller.First() + Expect(err).To(BeNil()) + Expect(len(first.Spec.Components)).To(Equal(2)) + Expect(first.ContainSameComponent("application", alpine.Spec.Components[0])).To(BeTrue()) + Expect(first.ContainSameComponent("application", node.Spec.Components[0])).To(BeTrue()) + + By("Removing all queues") + + err = controller.RemoveAllQueues() + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(0)) + }, 3) + + It("should successfully update component in existing bundle", func(done Done) { + defer close(done) + + var err error + var first *s2hv1beta1.Queue + var application = queue.NewUpgradeQueue(teamName, namespace, "application", "application", + s2hv1beta1.QueueComponents{ + {Name: "alpine", Version: "3.9.0"}, + {Name: "node", Version: "11.0.0"}, + }, + ) + var ubuntu = queue.NewUpgradeQueue(teamName, namespace, "ubuntu", "", + s2hv1beta1.QueueComponents{{Name: "ubuntu", Version: "18.04"}}, + ) + var node = queue.NewUpgradeQueue(teamName, namespace, "application", "application", + s2hv1beta1.QueueComponents{{Name: "node", Version: "11.0.2"}}, + ) + var size int + + Expect(controller.Size()).To(Equal(0), "should start with empty queue") + + By("Create 2 queue") + + err = controller.Add(application) + Expect(err).To(BeNil()) + err = controller.Add(ubuntu) + Expect(err).To(BeNil()) + + By("Update node application") + + err = controller.Add(node) + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(2)) + + first, err = controller.First() + Expect(err).To(BeNil()) + Expect(len(first.Spec.Components)).To(Equal(2)) + Expect(first.ContainSameComponent("application", application.Spec.Components[0])).To(BeTrue()) + Expect(first.ContainSameComponent("application", node.Spec.Components[0])).To(BeTrue()) + + By("Removing all queues") + + err = controller.RemoveAllQueues() + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(0)) + }, 3) + + It("should successfully remove queue/component from existing bundle and create new queue", func(done Done) { + defer close(done) + + var err error + var first *s2hv1beta1.Queue + var application = queue.NewUpgradeQueue(teamName, namespace, "application", "application", + s2hv1beta1.QueueComponents{ + {Name: "alpine", Version: "3.9.0"}, + {Name: "node", Version: "11.0.0"}, + }, + ) + var duplicatedNode = queue.NewUpgradeQueue(teamName, namespace, "node", "", + s2hv1beta1.QueueComponents{{Name: "node", Version: "11.0.1"}}, + ) + var node = queue.NewUpgradeQueue(teamName, namespace, "node", "", + s2hv1beta1.QueueComponents{{Name: "node", Version: "11.0.2"}}, + ) + var size int + + Expect(controller.Size()).To(Equal(0), "should start with empty queue") + + By("Create 2 queue") + + err = controller.Add(application) + Expect(err).To(BeNil()) + err = controller.Add(duplicatedNode) + Expect(err).To(BeNil()) + + By("Update node application to not in bundle") + + err = controller.Add(node) + Expect(err).To(BeNil()) + size = controller.Size() + Expect(size).To(Equal(2)) + + first, err = controller.First() + Expect(err).To(BeNil()) + Expect(len(first.Spec.Components)).To(Equal(1)) + Expect(first.ContainSameComponent("application", application.Spec.Components[0])).To(BeTrue()) By("Removing all queues") diff --git a/test/e2e/samsahai/ctrl.go b/test/e2e/samsahai/ctrl.go index 1b6b36f3..b345f765 100644 --- a/test/e2e/samsahai/ctrl.go +++ b/test/e2e/samsahai/ctrl.go @@ -1830,11 +1830,19 @@ var ( Items: []s2hv1beta1.Queue{ { ObjectMeta: metav1.ObjectMeta{Name: redisCompName, Namespace: stgNamespace}, - Spec: s2hv1beta1.QueueSpec{Name: redisCompName, Repository: "bitnami/redis", Version: "5.0.7-debian-9-r56"}, + Spec: s2hv1beta1.QueueSpec{Name: redisCompName, + Components: s2hv1beta1.QueueComponents{ + {Name: redisCompName, Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}, + }, + }, }, { ObjectMeta: metav1.ObjectMeta{Name: wordpressCompName, Namespace: stgNamespace}, - Spec: s2hv1beta1.QueueSpec{Name: wordpressCompName, Repository: "bitnami/wordpress", Version: "5.2.4-debian-9-r18"}, + Spec: s2hv1beta1.QueueSpec{Name: wordpressCompName, + Components: s2hv1beta1.QueueComponents{ + {Name: wordpressCompName, Repository: "bitnami/wordpress", Version: "5.2.4-debian-9-r18"}, + }, + }, }, }, } diff --git a/test/e2e/staging/ctrl.go b/test/e2e/staging/ctrl.go index f319cd60..c717b32a 100644 --- a/test/e2e/staging/ctrl.go +++ b/test/e2e/staging/ctrl.go @@ -354,8 +354,9 @@ var _ = Describe("[e2e] Staging controller", func() { Expect(client.Create(context.TODO(), &swp)).To(BeNil()) By("Creating Queue") - newQueue := queue.NewUpgradeQueue(teamName, namespace, - "redis", "bitnami/redis", "5.0.5-debian-9-r160") + newQueue := queue.NewUpgradeQueue(teamName, namespace, "redis", "", + s2hv1beta1.QueueComponents{{Name: "ubuntu", Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, + ) Expect(queueCtrl.Add(newQueue)).To(BeNil()) By("Deploying") @@ -504,7 +505,9 @@ var _ = Describe("[e2e] Staging controller", func() { "", "", "", internal.StagingConfig{}) go stagingCtrl.Start(chStop) - redis := queue.NewUpgradeQueue(teamName, namespace, "redis", "bitnami/redis", "5.0.5-debian-9-r160") + redis := queue.NewUpgradeQueue(teamName, namespace, "redis", "", + s2hv1beta1.QueueComponents{{Name: "ubuntu", Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, + ) Expect(client.Create(context.TODO(), redis)).To(BeNil()) qhl := &s2hv1beta1.QueueHistoryList{} From a157b231c1c5a81dc0126861a509936ae98726f5 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 17:54:58 +0700 Subject: [PATCH 10/12] :alien: Fix deprecated protobuf --- internal/util/protostruct/unit_test.go | 2 +- pkg/samsahai/rpc.pb.go | 65 ++++++++++++++ pkg/samsahai/rpc/service.pb.go | 7 +- pkg/samsahai/rpc/service.proto | 2 +- pkg/samsahai/rpc/service.twirp.go | 113 +++++++++++++------------ pkg/staging/rpc.pb.go | 65 ++++++++++++++ pkg/staging/rpc/service.pb.go | 6 +- pkg/staging/rpc/service.proto | 2 +- pkg/staging/rpc/service.twirp.go | 27 +++--- 9 files changed, 213 insertions(+), 76 deletions(-) create mode 100644 pkg/samsahai/rpc.pb.go create mode 100644 pkg/staging/rpc.pb.go diff --git a/internal/util/protostruct/unit_test.go b/internal/util/protostruct/unit_test.go index 18e09d32..49fa2b30 100644 --- a/internal/util/protostruct/unit_test.go +++ b/internal/util/protostruct/unit_test.go @@ -21,11 +21,11 @@ import ( "math/big" "testing" - "github.com/golang/protobuf/proto" pb "github.com/golang/protobuf/ptypes/struct" "github.com/google/go-cmp/cmp" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "google.golang.org/protobuf/proto" "github.com/agoda-com/samsahai/internal/util/unittest" ) diff --git a/pkg/samsahai/rpc.pb.go b/pkg/samsahai/rpc.pb.go new file mode 100644 index 00000000..753fc406 --- /dev/null +++ b/pkg/samsahai/rpc.pb.go @@ -0,0 +1,65 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.24.0-devel +// protoc v3.9.1 +// source: pkg/samsahai/rpc + +package rpc + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +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) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_pkg_samsahai_rpc protoreflect.FileDescriptor + +var file_pkg_samsahai_rpc_rawDesc = []byte{ + 0x0a, 0x10, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2f, 0x72, + 0x70, 0x63, +} + +var file_pkg_samsahai_rpc_goTypes = []interface{}{} +var file_pkg_samsahai_rpc_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_pkg_samsahai_rpc_init() } +func file_pkg_samsahai_rpc_init() { + if File_pkg_samsahai_rpc != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_samsahai_rpc_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_pkg_samsahai_rpc_goTypes, + DependencyIndexes: file_pkg_samsahai_rpc_depIdxs, + }.Build() + File_pkg_samsahai_rpc = out.File + file_pkg_samsahai_rpc_rawDesc = nil + file_pkg_samsahai_rpc_goTypes = nil + file_pkg_samsahai_rpc_depIdxs = nil +} diff --git a/pkg/samsahai/rpc/service.pb.go b/pkg/samsahai/rpc/service.pb.go index 2fff8a56..1edd24c8 100644 --- a/pkg/samsahai/rpc/service.pb.go +++ b/pkg/samsahai/rpc/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.23.0-devel +// protoc-gen-go v1.24.0-devel // protoc v3.9.1 // source: pkg/samsahai/rpc/service.proto @@ -780,8 +780,9 @@ var file_pkg_samsahai_rpc_service_proto_rawDesc = []byte{ 0x68, 0x61, 0x69, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x1a, 0x20, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, - 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x05, 0x5a, 0x03, 0x72, - 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x12, 0x5a, 0x10, 0x70, + 0x6b, 0x67, 0x2f, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/samsahai/rpc/service.proto b/pkg/samsahai/rpc/service.proto index a4c661e9..f30f7a7b 100644 --- a/pkg/samsahai/rpc/service.proto +++ b/pkg/samsahai/rpc/service.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package samsahai.io.samsahai; -option go_package = "rpc"; +option go_package = "pkg/samsahai/rpc"; service RPC { rpc RunPostComponentUpgrade (ComponentUpgrade) returns (Empty); diff --git a/pkg/samsahai/rpc/service.twirp.go b/pkg/samsahai/rpc/service.twirp.go index 7b3ba2e5..ddfe99ed 100644 --- a/pkg/samsahai/rpc/service.twirp.go +++ b/pkg/samsahai/rpc/service.twirp.go @@ -1,9 +1,9 @@ -// Code generated by protoc-gen-twirp v5.10.2, DO NOT EDIT. +// Code generated by protoc-gen-twirp v5.11.0, DO NOT EDIT. // source: pkg/samsahai/rpc/service.proto /* Package rpc is a generated twirp stub package. -This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.2. +This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.11.0. It is generated from these files: pkg/samsahai/rpc/service.proto @@ -865,7 +865,7 @@ func (s *rPCServer) ServiceDescriptor() ([]byte, int) { } func (s *rPCServer) ProtocGenTwirpVersion() string { - return "v5.10.2" + return "v5.11.0" } func (s *rPCServer) PathPrefix() string { @@ -1006,7 +1006,7 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType } req.Header.Set("Accept", contentType) req.Header.Set("Content-Type", contentType) - req.Header.Set("Twirp-Version", "v5.10.2") + req.Header.Set("Twirp-Version", "v5.11.0") return req, nil } @@ -1134,8 +1134,9 @@ type wrappedError struct { cause error } -func (e *wrappedError) Cause() error { return e.cause } func (e *wrappedError) Error() string { return e.prefix + ": " + e.cause.Error() } +func (e *wrappedError) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *wrappedError) Cause() error { return e.cause } // for github.com/pkg/errors // ensurePanicResponses makes sure that rpc methods causing a panic still result in a Twirp Internal // error response (status 500), and error hooks are properly called with the panic wrapped as an error. @@ -1166,14 +1167,16 @@ func errFromPanic(p interface{}) error { return fmt.Errorf("panic: %v", p) } -// internalWithCause is a Twirp Internal error wrapping an original error cause, accessible -// by github.com/pkg/errors.Cause, but the original error message is not exposed on Msg(). +// internalWithCause is a Twirp Internal error wrapping an original error cause, +// but the original error message is not exposed on Msg(). The original error +// can be checked with go1.13+ errors.Is/As, and also by (github.com/pkg/errors).Unwrap type internalWithCause struct { msg string cause error } -func (e *internalWithCause) Cause() error { return e.cause } +func (e *internalWithCause) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *internalWithCause) Cause() error { return e.cause } // for github.com/pkg/errors func (e *internalWithCause) Error() string { return e.msg + ": " + e.cause.Error() } func (e *internalWithCause) Code() twirp.ErrorCode { return twirp.Internal } func (e *internalWithCause) Msg() string { return e.msg } @@ -1385,51 +1388,51 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 732 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5f, 0x4f, 0xd3, 0x50, - 0x14, 0xa7, 0x1b, 0x1b, 0xec, 0x20, 0x5a, 0x6e, 0x20, 0xd4, 0x41, 0xa0, 0x69, 0x88, 0x59, 0x34, - 0x19, 0x0a, 0xbe, 0x18, 0x1f, 0x14, 0xb6, 0x3a, 0x1b, 0x59, 0xc1, 0x5b, 0x06, 0xd1, 0x07, 0x96, - 0xba, 0x5d, 0xc7, 0x8d, 0xac, 0xad, 0xf7, 0xde, 0x62, 0x96, 0xf8, 0xec, 0xa3, 0xdf, 0xcd, 0x6f, - 0x64, 0x7a, 0xd9, 0xda, 0x8e, 0x75, 0x0c, 0x13, 0x9f, 0x7a, 0x7a, 0xee, 0xef, 0xfc, 0xf9, 0x9d, - 0x7b, 0xce, 0xb9, 0xb0, 0x15, 0x7c, 0xeb, 0xed, 0x72, 0xb7, 0xcf, 0xdd, 0x4b, 0x97, 0xee, 0xb2, - 0xa0, 0xb3, 0xcb, 0x09, 0xbb, 0xa6, 0x1d, 0x52, 0x0d, 0x98, 0x2f, 0x7c, 0xb4, 0x3a, 0x3a, 0xab, - 0x52, 0xbf, 0x3a, 0x92, 0x8d, 0x05, 0x28, 0x98, 0xfd, 0x40, 0x0c, 0x8c, 0x4f, 0xb0, 0x76, 0x4a, - 0xdc, 0xfe, 0x39, 0x15, 0x97, 0x35, 0xbf, 0x1f, 0xf8, 0x1e, 0xf1, 0x84, 0xed, 0xf6, 0x09, 0x2a, - 0xc3, 0xa2, 0x20, 0x6e, 0x3f, 0x92, 0x35, 0x45, 0x57, 0x2a, 0x25, 0x1c, 0xff, 0xa3, 0x1d, 0x58, - 0xee, 0xa4, 0xc1, 0x5a, 0x4e, 0x02, 0xc6, 0x95, 0x86, 0x0e, 0x70, 0x18, 0x7a, 0xdd, 0x2b, 0x22, - 0x6d, 0x10, 0xcc, 0x7b, 0x89, 0x2f, 0x29, 0x1b, 0x7f, 0x16, 0x40, 0x8d, 0xa3, 0xb6, 0x82, 0x1e, - 0x73, 0xbb, 0x04, 0x1d, 0x41, 0x91, 0x0b, 0x57, 0x84, 0x5c, 0x42, 0x1f, 0xee, 0xbd, 0xac, 0x66, - 0x31, 0xa8, 0xde, 0xb6, 0xab, 0x0e, 0xbf, 0x8e, 0xb4, 0xc5, 0x43, 0x1f, 0x71, 0xd8, 0x5c, 0x12, - 0x76, 0x8c, 0x5a, 0xfe, 0x16, 0xb5, 0x37, 0x00, 0x31, 0x0b, 0xae, 0xcd, 0xeb, 0xf9, 0xca, 0xd2, - 0xde, 0xf6, 0x8c, 0x0c, 0x70, 0xca, 0x04, 0xd9, 0x50, 0xa2, 0x9c, 0x87, 0xe4, 0x74, 0x10, 0x10, - 0xad, 0x20, 0x19, 0x3c, 0xbf, 0x27, 0x03, 0x6b, 0x64, 0x87, 0x13, 0x17, 0xe8, 0x29, 0xa8, 0xdf, - 0x43, 0x12, 0x92, 0xf7, 0x94, 0x0b, 0x9f, 0x0d, 0x64, 0xd2, 0x45, 0x99, 0xf4, 0x84, 0x1e, 0x35, - 0x40, 0xa5, 0x7d, 0xb7, 0x47, 0x9a, 0x94, 0x73, 0xea, 0xf5, 0x8e, 0x28, 0x17, 0xda, 0x82, 0xa4, - 0xb0, 0x91, 0x9d, 0x82, 0x15, 0xa1, 0xf1, 0x84, 0x11, 0xda, 0x84, 0x52, 0x54, 0x29, 0x1e, 0xb8, - 0x1d, 0xa2, 0x2d, 0xca, 0x68, 0x89, 0x02, 0x55, 0xe0, 0x91, 0x20, 0x5c, 0x1c, 0x86, 0xf4, 0xaa, - 0x1b, 0xe5,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, 0x5c, 0x95, 0xf5, 0x6c, - 0x70, 0xe2, 0xee, 0xb0, 0xf0, 0x39, 0xcf, 0x82, 0xce, 0x97, 0xa2, 0x7c, 0x58, 0xf7, 0xff, 0x06, - 0x00, 0x00, 0xff, 0xff, 0x4e, 0xd9, 0x30, 0xf6, 0x7a, 0x07, 0x00, 0x00, + // 734 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x4f, 0xdb, 0x4a, + 0x10, 0xc7, 0x09, 0x09, 0x64, 0x78, 0xbc, 0x67, 0x56, 0x20, 0xfc, 0x02, 0x02, 0xcb, 0x42, 0x55, + 0xd4, 0x4a, 0xa1, 0x85, 0x5e, 0xaa, 0x1e, 0x5a, 0x48, 0xdc, 0xd4, 0x2a, 0x31, 0x74, 0x4d, 0x40, + 0xed, 0x81, 0x68, 0x9b, 0x6c, 0xc3, 0xaa, 0xc4, 0x76, 0xbd, 0x6b, 0xaa, 0x48, 0x3d, 0xf7, 0xd8, + 0xef, 0xd6, 0x6f, 0x54, 0x79, 0x49, 0x6c, 0x27, 0x71, 0x08, 0x95, 0x7a, 0xf2, 0x78, 0xf6, 0x37, + 0xb3, 0xf3, 0x9b, 0x9d, 0x3f, 0xb0, 0xe3, 0x7f, 0xe9, 0xed, 0x73, 0xd2, 0xe7, 0xe4, 0x9a, 0xb0, + 0xfd, 0xc0, 0xef, 0xec, 0x73, 0x1a, 0xdc, 0xb2, 0x0e, 0xad, 0xfa, 0x81, 0x27, 0x3c, 0xb4, 0x3e, + 0x3a, 0xab, 0x32, 0xaf, 0x3a, 0x92, 0x8d, 0x25, 0x28, 0x98, 0x7d, 0x5f, 0x0c, 0x8c, 0x0f, 0xb0, + 0x71, 0x4e, 0x49, 0xff, 0x92, 0x89, 0xeb, 0x9a, 0xd7, 0xf7, 0x3d, 0x97, 0xba, 0xc2, 0x26, 0x7d, + 0x8a, 0xca, 0x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, 0x0d, 0x2a, 0x52, 0x3b, 0xe7, 0xc9, 0x1c, 0x12, 0xe9, 0x75, 0x55, + 0xd6, 0xb3, 0xc1, 0x89, 0xbb, 0x63, 0xf4, 0x51, 0x9d, 0x5c, 0xb6, 0x9f, 0x8a, 0x72, 0xcb, 0x1e, + 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x78, 0xff, 0x86, 0x8a, 0x87, 0x07, 0x00, 0x00, } diff --git a/pkg/staging/rpc.pb.go b/pkg/staging/rpc.pb.go new file mode 100644 index 00000000..1c74f4f2 --- /dev/null +++ b/pkg/staging/rpc.pb.go @@ -0,0 +1,65 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.24.0-devel +// protoc v3.9.1 +// source: pkg/staging/rpc + +package rpc + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +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) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_pkg_staging_rpc protoreflect.FileDescriptor + +var file_pkg_staging_rpc_rawDesc = []byte{ + 0x0a, 0x0f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x70, + 0x63, +} + +var file_pkg_staging_rpc_goTypes = []interface{}{} +var file_pkg_staging_rpc_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_pkg_staging_rpc_init() } +func file_pkg_staging_rpc_init() { + if File_pkg_staging_rpc != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_staging_rpc_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_pkg_staging_rpc_goTypes, + DependencyIndexes: file_pkg_staging_rpc_depIdxs, + }.Build() + File_pkg_staging_rpc = out.File + file_pkg_staging_rpc_rawDesc = nil + file_pkg_staging_rpc_goTypes = nil + file_pkg_staging_rpc_depIdxs = nil +} diff --git a/pkg/staging/rpc/service.pb.go b/pkg/staging/rpc/service.pb.go index 242bd7fb..f1bc5e31 100644 --- a/pkg/staging/rpc/service.pb.go +++ b/pkg/staging/rpc/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.23.0-devel +// protoc-gen-go v1.24.0-devel // protoc v3.9.1 // source: pkg/staging/rpc/service.proto @@ -70,8 +70,8 @@ var file_pkg_staging_rpc_service_proto_rawDesc = []byte{ 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x73, 0x61, 0x6d, 0x73, 0x61, 0x68, 0x61, 0x69, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x05, 0x0a, - 0x03, 0x52, 0x50, 0x43, 0x42, 0x05, 0x5a, 0x03, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x03, 0x52, 0x50, 0x43, 0x42, 0x11, 0x5a, 0x0f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x74, 0x61, 0x67, + 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/staging/rpc/service.proto b/pkg/staging/rpc/service.proto index 8f6252b4..deb8b42f 100644 --- a/pkg/staging/rpc/service.proto +++ b/pkg/staging/rpc/service.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package samsahai.io.staging; -option go_package = "rpc"; +option go_package = "pkg/staging/rpc"; service RPC { } diff --git a/pkg/staging/rpc/service.twirp.go b/pkg/staging/rpc/service.twirp.go index 0cf5833b..c7a1e950 100644 --- a/pkg/staging/rpc/service.twirp.go +++ b/pkg/staging/rpc/service.twirp.go @@ -1,9 +1,9 @@ -// Code generated by protoc-gen-twirp v5.10.2, DO NOT EDIT. +// Code generated by protoc-gen-twirp v5.11.0, DO NOT EDIT. // source: pkg/staging/rpc/service.proto /* Package rpc is a generated twirp stub package. -This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.2. +This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.11.0. It is generated from these files: pkg/staging/rpc/service.proto @@ -157,7 +157,7 @@ func (s *rPCServer) ServiceDescriptor() ([]byte, int) { } func (s *rPCServer) ProtocGenTwirpVersion() string { - return "v5.10.2" + return "v5.11.0" } func (s *rPCServer) PathPrefix() string { @@ -298,7 +298,7 @@ func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType } req.Header.Set("Accept", contentType) req.Header.Set("Content-Type", contentType) - req.Header.Set("Twirp-Version", "v5.10.2") + req.Header.Set("Twirp-Version", "v5.11.0") return req, nil } @@ -426,8 +426,9 @@ type wrappedError struct { cause error } -func (e *wrappedError) Cause() error { return e.cause } func (e *wrappedError) Error() string { return e.prefix + ": " + e.cause.Error() } +func (e *wrappedError) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *wrappedError) Cause() error { return e.cause } // for github.com/pkg/errors // ensurePanicResponses makes sure that rpc methods causing a panic still result in a Twirp Internal // error response (status 500), and error hooks are properly called with the panic wrapped as an error. @@ -458,14 +459,16 @@ func errFromPanic(p interface{}) error { return fmt.Errorf("panic: %v", p) } -// internalWithCause is a Twirp Internal error wrapping an original error cause, accessible -// by github.com/pkg/errors.Cause, but the original error message is not exposed on Msg(). +// internalWithCause is a Twirp Internal error wrapping an original error cause, +// but the original error message is not exposed on Msg(). The original error +// can be checked with go1.13+ errors.Is/As, and also by (github.com/pkg/errors).Unwrap type internalWithCause struct { msg string cause error } -func (e *internalWithCause) Cause() error { return e.cause } +func (e *internalWithCause) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *internalWithCause) Cause() error { return e.cause } // for github.com/pkg/errors func (e *internalWithCause) Error() string { return e.msg + ": " + e.cause.Error() } func (e *internalWithCause) Code() twirp.ErrorCode { return twirp.Internal } func (e *internalWithCause) Msg() string { return e.msg } @@ -677,12 +680,12 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 99 bytes of a gzipped FileDescriptorProto + // 98 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0x4e, 0xd7, 0x2f, 0x2e, 0x49, 0x4c, 0xcf, 0xcc, 0x4b, 0xd7, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0x2d, 0x4e, 0xcc, 0x48, 0xcc, 0xd4, 0xcb, 0xcc, 0xd7, 0x83, 0x2a, 0x53, 0x62, 0xe7, 0x62, 0x75, 0xcd, 0x2d, - 0x28, 0xa9, 0x34, 0x62, 0xe5, 0x62, 0x0e, 0x0a, 0x70, 0x76, 0x62, 0x8d, 0x62, 0x2e, 0x2a, 0x48, - 0x4e, 0x62, 0x03, 0x6b, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x04, 0xa0, 0x3d, 0xa6, 0x53, - 0x00, 0x00, 0x00, + 0x28, 0xa9, 0x34, 0x62, 0xe5, 0x62, 0x0e, 0x0a, 0x70, 0x76, 0x12, 0x8c, 0xe2, 0x47, 0x33, 0x25, + 0x89, 0x0d, 0xac, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x80, 0x17, 0xd4, 0x30, 0x5f, 0x00, + 0x00, 0x00, } From 8fcbd135c4ae7b6ac674b92cd3da9005b6af2929 Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 20:02:24 +0700 Subject: [PATCH 11/12] :white_check_mark: Fix test --- docs/docs.go | 74 ++++++++++++++++++---- docs/swagger.json | 72 +++++++++++++++++---- docs/swagger.yaml | 59 ++++++++++++++--- internal/reporter.go | 2 +- internal/reporter/msteams/reporter.go | 4 +- internal/reporter/reportermock/reporter.go | 2 +- internal/reporter/rest/reporter.go | 8 +-- internal/reporter/rest/reporter_test.go | 4 +- internal/reporter/shell/reporter.go | 4 +- internal/reporter/shell/reporter_test.go | 2 +- internal/reporter/slack/reporter.go | 4 +- 11 files changed, 183 insertions(+), 52 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 866a6f9b..0244d079 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-05-15 14:13:57.350441 +0700 +07 m=+0.125952034 +// 2020-06-04 19:59:19.001528 +0700 +07 m=+0.092083914 package docs @@ -931,6 +931,13 @@ var doc = `{ } } }, + "v1beta1.ConfigBundles": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": {} + } + }, "v1beta1.ConfigComponentUpgrade": { "type": "object", "properties": { @@ -1010,6 +1017,11 @@ var doc = `{ "type": "object", "$ref": "#/definitions/v1beta1.ConfigActivePromotion" }, + "bundles": { + "description": "Bundles represents a group of component for each bundle\n+optional", + "type": "object", + "$ref": "#/definitions/v1beta1.ConfigBundles" + }, "components": { "description": "Components represents all components that are managed", "type": "array", @@ -1182,6 +1194,43 @@ var doc = `{ } } }, + "v1beta1.QueueComponent": { + "type": "object", + "properties": { + "name": { + "description": "Name represents Component name", + "type": "string" + }, + "repository": { + "description": "Repository represents Docker image repository", + "type": "string" + }, + "version": { + "description": "Version represents Docker image tag version", + "type": "string" + } + } + }, + "v1beta1.QueueComponents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "description": "Name represents Component name", + "type": "string" + }, + "repository": { + "description": "Repository represents Docker image repository", + "type": "string" + }, + "version": { + "description": "Version represents Docker image tag version", + "type": "string" + } + } + } + }, "v1beta1.QueueCondition": { "type": "object", "properties": { @@ -1255,8 +1304,17 @@ var doc = `{ "v1beta1.QueueSpec": { "type": "object", "properties": { + "bundle": { + "description": "Bundle represents a bundle name of component\n+optional", + "type": "string" + }, + "components": { + "description": "Components represents a list of components which are deployed\n+optional", + "type": "object", + "$ref": "#/definitions/v1beta1.QueueComponents" + }, "name": { - "description": "Name represents Component name", + "description": "Name represents a Component name or bundle name if exist", "type": "string" }, "nextProcessAt": { @@ -1271,10 +1329,6 @@ var doc = `{ "description": "NoOfRetry defines how many times this component has been tested\n+optional", "type": "integer" }, - "repository": { - "description": "Repository represents Docker image repository", - "type": "string" - }, "teamName": { "description": "TeamName represents team owner of the queue", "type": "string" @@ -1282,10 +1336,6 @@ var doc = `{ "type": { "description": "Type represents how we will process this queue", "type": "string" - }, - "version": { - "description": "Version represents Docker image tag version", - "type": "string" } } }, @@ -1330,10 +1380,6 @@ var doc = `{ "description": "QueueHistoryName defines name of history of this queue", "type": "string" }, - "releaseName": { - "description": "ReleaseName defines name of helmrelease", - "type": "string" - }, "startDeployTime": { "description": "StartDeployTime represents the time when this queue start deploying", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 25be8cc2..cc2ee106 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -910,6 +910,13 @@ } } }, + "v1beta1.ConfigBundles": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": {} + } + }, "v1beta1.ConfigComponentUpgrade": { "type": "object", "properties": { @@ -989,6 +996,11 @@ "type": "object", "$ref": "#/definitions/v1beta1.ConfigActivePromotion" }, + "bundles": { + "description": "Bundles represents a group of component for each bundle\n+optional", + "type": "object", + "$ref": "#/definitions/v1beta1.ConfigBundles" + }, "components": { "description": "Components represents all components that are managed", "type": "array", @@ -1161,6 +1173,43 @@ } } }, + "v1beta1.QueueComponent": { + "type": "object", + "properties": { + "name": { + "description": "Name represents Component name", + "type": "string" + }, + "repository": { + "description": "Repository represents Docker image repository", + "type": "string" + }, + "version": { + "description": "Version represents Docker image tag version", + "type": "string" + } + } + }, + "v1beta1.QueueComponents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "description": "Name represents Component name", + "type": "string" + }, + "repository": { + "description": "Repository represents Docker image repository", + "type": "string" + }, + "version": { + "description": "Version represents Docker image tag version", + "type": "string" + } + } + } + }, "v1beta1.QueueCondition": { "type": "object", "properties": { @@ -1234,8 +1283,17 @@ "v1beta1.QueueSpec": { "type": "object", "properties": { + "bundle": { + "description": "Bundle represents a bundle name of component\n+optional", + "type": "string" + }, + "components": { + "description": "Components represents a list of components which are deployed\n+optional", + "type": "object", + "$ref": "#/definitions/v1beta1.QueueComponents" + }, "name": { - "description": "Name represents Component name", + "description": "Name represents a Component name or bundle name if exist", "type": "string" }, "nextProcessAt": { @@ -1250,10 +1308,6 @@ "description": "NoOfRetry defines how many times this component has been tested\n+optional", "type": "integer" }, - "repository": { - "description": "Repository represents Docker image repository", - "type": "string" - }, "teamName": { "description": "TeamName represents team owner of the queue", "type": "string" @@ -1261,10 +1315,6 @@ "type": { "description": "Type represents how we will process this queue", "type": "string" - }, - "version": { - "description": "Version represents Docker image tag version", - "type": "string" } } }, @@ -1309,10 +1359,6 @@ "description": "QueueHistoryName defines name of history of this queue", "type": "string" }, - "releaseName": { - "description": "ReleaseName defines name of helmrelease", - "type": "string" - }, "startDeployTime": { "description": "StartDeployTime represents the time when this queue start deploying", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 72a73850..4fde8d93 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -251,6 +251,11 @@ definitions: +optional type: string type: object + v1beta1.ConfigBundles: + additionalProperties: + items: {} + type: array + type: object v1beta1.ConfigComponentUpgrade: properties: criteria: @@ -323,6 +328,12 @@ definitions: ActivePromotion represents configuration about active promotion +optional type: object + bundles: + $ref: '#/definitions/v1beta1.ConfigBundles' + description: |- + Bundles represents a group of component for each bundle + +optional + type: object components: description: Components represents all components that are managed items: @@ -453,6 +464,32 @@ definitions: $ref: '#/definitions/v1beta1.QueueStatus' type: object type: object + v1beta1.QueueComponent: + properties: + name: + description: Name represents Component name + type: string + repository: + description: Repository represents Docker image repository + type: string + version: + description: Version represents Docker image tag version + type: string + type: object + v1beta1.QueueComponents: + items: + properties: + name: + description: Name represents Component name + type: string + repository: + description: Repository represents Docker image repository + type: string + version: + description: Version represents Docker image tag version + type: string + type: object + type: array v1beta1.QueueCondition: properties: lastTransitionTime: @@ -503,8 +540,19 @@ definitions: type: object v1beta1.QueueSpec: properties: + bundle: + description: |- + Bundle represents a bundle name of component + +optional + type: string + components: + $ref: '#/definitions/v1beta1.QueueComponents' + description: |- + Components represents a list of components which are deployed + +optional + type: object name: - description: Name represents Component name + description: Name represents a Component name or bundle name if exist type: string nextProcessAt: description: NextProcessAt represents time to wait for process this queue @@ -519,18 +567,12 @@ definitions: NoOfRetry defines how many times this component has been tested +optional type: integer - repository: - description: Repository represents Docker image repository - type: string teamName: description: TeamName represents team owner of the queue type: string type: description: Type represents how we will process this queue type: string - version: - description: Version represents Docker image tag version - type: string type: object v1beta1.QueueStatus: properties: @@ -570,9 +612,6 @@ definitions: queueHistoryName: description: QueueHistoryName defines name of history of this queue type: string - releaseName: - description: ReleaseName defines name of helmrelease - type: string startDeployTime: description: StartDeployTime represents the time when this queue start deploying type: string diff --git a/internal/reporter.go b/internal/reporter.go index 409b6c99..43872356 100644 --- a/internal/reporter.go +++ b/internal/reporter.go @@ -137,7 +137,7 @@ type Reporter interface { SendActivePromotionStatus(configCtrl ConfigController, atpRpt *ActivePromotionReporter) error // SendImageMissing sends image missing - SendImageMissing(teamName string, configCtrl ConfigController, images *rpc.Image) error + SendImageMissing(teamName string, configCtrl ConfigController, image *rpc.Image) error } func convertIssueType(issueType rpc.ComponentUpgrade_IssueType) IssueType { diff --git a/internal/reporter/msteams/reporter.go b/internal/reporter/msteams/reporter.go index 6ae14a2a..3df1d3c7 100644 --- a/internal/reporter/msteams/reporter.go +++ b/internal/reporter/msteams/reporter.go @@ -187,13 +187,13 @@ func convertImageListToRPCImageList(images []s2hv1beta1.Image) []*rpc.Image { } // SendImageMissing implements the reporter SendImageMissing function -func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, images *rpc.Image) error { +func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, image *rpc.Image) error { msTeamsConfig, err := r.getMSTeamsConfig(teamName, configCtrl) if err != nil { return nil } - message := r.makeImageMissingListReport([]*rpc.Image{images}) + message := r.makeImageMissingListReport([]*rpc.Image{image}) return r.post(msTeamsConfig, message, internal.ImageMissingType) } diff --git a/internal/reporter/reportermock/reporter.go b/internal/reporter/reportermock/reporter.go index c9581a4d..e23238fd 100644 --- a/internal/reporter/reportermock/reporter.go +++ b/internal/reporter/reportermock/reporter.go @@ -37,6 +37,6 @@ func (r *reporterMock) SendActivePromotionStatus(configCtrl internal.ConfigContr } // SendImageMissing implements the reporter SendImageMissingList function -func (r *reporterMock) SendImageMissing(teamName string, configCtrl internal.ConfigController, images *rpc.Image) error { +func (r *reporterMock) SendImageMissing(teamName string, configCtrl internal.ConfigController, image *rpc.Image) error { return nil } diff --git a/internal/reporter/rest/reporter.go b/internal/reporter/rest/reporter.go index 9e9695df..d84b22df 100644 --- a/internal/reporter/rest/reporter.go +++ b/internal/reporter/rest/reporter.go @@ -32,12 +32,12 @@ type ReporterJSON struct { type componentUpgradeRest struct { ReporterJSON - *internal.ComponentUpgradeReporter + internal.ComponentUpgradeReporter } type activePromotionRest struct { ReporterJSON - *internal.ActivePromotionReporter + internal.ActivePromotionReporter } type imageMissingRest struct { @@ -103,7 +103,7 @@ func (r *reporter) SendComponentUpgrade(configCtrl internal.ConfigController, co } for _, ep := range config.Spec.Reporter.Rest.ComponentUpgrade.Endpoints { - restObj := &componentUpgradeRest{NewReporterJSON(), comp} + restObj := &componentUpgradeRest{NewReporterJSON(), *comp} body, err := json.Marshal(restObj) if err != nil { logger.Error(err, fmt.Sprintf("cannot convert struct to json object, %v", body)) @@ -132,7 +132,7 @@ func (r *reporter) SendActivePromotionStatus(configCtrl internal.ConfigControlle } for _, ep := range config.Spec.Reporter.Rest.ActivePromotion.Endpoints { - restObj := &activePromotionRest{NewReporterJSON(), atpRpt} + restObj := &activePromotionRest{NewReporterJSON(), *atpRpt} body, err := json.Marshal(restObj) if err != nil { logger.Error(err, fmt.Sprintf("cannot convert struct to json object, %v", body)) diff --git a/internal/reporter/rest/reporter_test.go b/internal/reporter/rest/reporter_test.go index 64f45459..8f05f81e 100644 --- a/internal/reporter/rest/reporter_test.go +++ b/internal/reporter/rest/reporter_test.go @@ -195,7 +195,7 @@ var _ = Describe("send rest message", func() { client := rest.New(rest.WithRestClient(rest.NewRest(server.URL))) configCtrl := newMockConfigCtrl("") - err := client.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{}) + err := client.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{ComponentUpgrade: &rpc.ComponentUpgrade{}}) g.Expect(err).NotTo(BeNil(), "component upgrade request should thrown an error") err = client.SendActivePromotionStatus(configCtrl, &internal.ActivePromotionReporter{}) @@ -221,7 +221,7 @@ var _ = Describe("send rest message", func() { client := rest.New(rest.WithRestClient(rest.NewRest(server.URL))) configCtrl := newMockConfigCtrl("empty") - err := client.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{}) + err := client.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{ComponentUpgrade: &rpc.ComponentUpgrade{}}) g.Expect(err).NotTo(HaveOccurred()) g.Expect(calls).To(Equal(0)) diff --git a/internal/reporter/shell/reporter.go b/internal/reporter/shell/reporter.go index 88c0461f..a68ccbea 100644 --- a/internal/reporter/shell/reporter.go +++ b/internal/reporter/shell/reporter.go @@ -110,7 +110,7 @@ func (r *reporter) SendActivePromotionStatus(configCtrl internal.ConfigControlle } // SendImageMissing implements the reporter SendImageMissing function -func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, images *rpc.Image) error { +func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, image *rpc.Image) error { config, err := configCtrl.Get(teamName) if err != nil { return err @@ -123,7 +123,7 @@ func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigC } cmdObj := cmd.RenderTemplate(config.Spec.Reporter.Shell.ImageMissing.Command, - config.Spec.Reporter.Shell.ImageMissing.Args, images) + config.Spec.Reporter.Shell.ImageMissing.Args, image) if err := r.execute(cmdObj, internal.ImageMissingType); err != nil { return err } diff --git a/internal/reporter/shell/reporter_test.go b/internal/reporter/shell/reporter_test.go index f6bc7f79..b7ca890d 100644 --- a/internal/reporter/shell/reporter_test.go +++ b/internal/reporter/shell/reporter_test.go @@ -121,7 +121,7 @@ var _ = Describe("shell command reporter", func() { r := shell.New(shell.WithExecCommand(mockExecCommand)) configCtrl := newMockConfigCtrl("empty") - err := r.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{}) + err := r.SendComponentUpgrade(configCtrl, &internal.ComponentUpgradeReporter{ComponentUpgrade: &rpc.ComponentUpgrade{}}) g.Expect(err).NotTo(HaveOccurred()) g.Expect(calls).To(Equal(0)) diff --git a/internal/reporter/slack/reporter.go b/internal/reporter/slack/reporter.go index 54492200..b6f6b55b 100644 --- a/internal/reporter/slack/reporter.go +++ b/internal/reporter/slack/reporter.go @@ -183,13 +183,13 @@ func convertImageListToRPCImageList(images []s2hv1beta1.Image) []*rpc.Image { } // SendImageMissing implements the reporter SendImageMissing function -func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, images *rpc.Image) error { +func (r *reporter) SendImageMissing(teamName string, configCtrl internal.ConfigController, image *rpc.Image) error { slackConfig, err := r.getSlackConfig(teamName, configCtrl) if err != nil { return nil } - message := r.makeImageMissingListReport([]*rpc.Image{images}) + message := r.makeImageMissingListReport([]*rpc.Image{image}) return r.post(slackConfig, message, internal.ImageMissingType) } From 5e33fc279d0a80925706e6cc0580a8f8e7b8001c Mon Sep 17 00:00:00 2001 From: Kornchanok Jiravesayakul Date: Thu, 4 Jun 2020 21:38:32 +0700 Subject: [PATCH 12/12] :white_check_mark: Update staging ctrl test --- docs/docs.go | 2 +- internal/queue/controller.go | 5 +- internal/staging/collect_result.go | 4 +- test/e2e/queue/ctrl.go | 2 +- test/e2e/staging/ctrl.go | 120 +++++++++++++++++++++++------ 5 files changed, 102 insertions(+), 31 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 0244d079..1e873fd9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-06-04 19:59:19.001528 +0700 +07 m=+0.092083914 +// 2020-06-05 09:08:53.407712 +0700 +07 m=+0.253929246 package docs diff --git a/internal/queue/controller.go b/internal/queue/controller.go index e7129d80..f618471a 100644 --- a/internal/queue/controller.go +++ b/internal/queue/controller.go @@ -176,10 +176,7 @@ func (c *controller) add(ctx context.Context, queue *s2hv1beta1.Queue, atTop boo now := metav1.Now() if isAlreadyInQueue { - var isQueueOnTop bool - if len(queueList.Items[0].Spec.Components) > 0 { - isQueueOnTop = pQueue.ContainSameComponent(queueList.Items[0].Spec.Name, queueList.Items[0].Spec.Components[0]) - } + isQueueOnTop := queueList.Items[0].ContainSameComponent(pQueue.Spec.Name, pQueue.Spec.Components[0]) // move queue to the top if atTop && !isQueueOnTop { diff --git a/internal/staging/collect_result.go b/internal/staging/collect_result.go index a26d66b9..8dedbc3d 100644 --- a/internal/staging/collect_result.go +++ b/internal/staging/collect_result.go @@ -224,7 +224,7 @@ func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { return } - return nil + continue } else if err != nil { logger.Error(err, fmt.Sprintf("cannot get StableComponent: %s/%s", queue.GetNamespace(), qComp.Name)) @@ -234,7 +234,7 @@ func (c *controller) setStableComponent(queue *s2hv1beta1.Queue) (err error) { if stableComp.Spec.Version == qComp.Version && stableComp.Spec.Repository == qComp.Repository { // no change - return nil + continue } stableComp.Spec.Repository = qComp.Repository diff --git a/test/e2e/queue/ctrl.go b/test/e2e/queue/ctrl.go index 9fe8ac7d..7d5d8a56 100644 --- a/test/e2e/queue/ctrl.go +++ b/test/e2e/queue/ctrl.go @@ -142,7 +142,7 @@ var _ = Describe("[e2e] Queue controller", func() { Expect(size).To(Equal(0)) }, 3) - It("should successfully update component to existing bundle", func(done Done) { + It("should successfully add component to existing bundle", func(done Done) { defer close(done) var err error diff --git a/test/e2e/staging/ctrl.go b/test/e2e/staging/ctrl.go index c717b32a..613174de 100644 --- a/test/e2e/staging/ctrl.go +++ b/test/e2e/staging/ctrl.go @@ -58,24 +58,28 @@ var _ = Describe("[e2e] Staging controller", func() { logger := s2hlog.Log.WithName(fmt.Sprintf("%s-test", internal.StagingCtrlName)) + redisCompName := "redis" + mariaDBCompName := "mariadb" + wordpressCompName := "wordpress" + stableWordPress := s2hv1beta1.StableComponent{ ObjectMeta: metav1.ObjectMeta{ - Name: "wordpress", + Name: wordpressCompName, Namespace: namespace, }, Spec: s2hv1beta1.StableComponentSpec{ - Name: "wordpress", + Name: wordpressCompName, Version: "5.2.2-debian-9-r2", Repository: "bitnami/wordpress", }, } stableMariaDB := s2hv1beta1.StableComponent{ ObjectMeta: metav1.ObjectMeta{ - Name: "mariadb", + Name: mariaDBCompName, Namespace: namespace, }, Spec: s2hv1beta1.StableComponentSpec{ - Name: "mariadb", + Name: mariaDBCompName, Version: "10.3.16-debian-9-r9", Repository: "bitnami/mariadb", }, @@ -147,11 +151,11 @@ var _ = Describe("[e2e] Staging controller", func() { }, } compSource := s2hv1beta1.UpdatingSource("public-registry") - redisConfigComp := s2hv1beta1.Component{ - Name: "redis", + configCompRedis := s2hv1beta1.Component{ + Name: redisCompName, Chart: s2hv1beta1.ComponentChart{ Repository: "https://kubernetes-charts.storage.googleapis.com", - Name: "redis", + Name: redisCompName, }, Image: s2hv1beta1.ComponentImage{ Repository: "bitnami/redis", @@ -175,6 +179,49 @@ var _ = Describe("[e2e] Staging controller", func() { }, } + configCompWordpress := s2hv1beta1.Component{ + Name: wordpressCompName, + Chart: s2hv1beta1.ComponentChart{ + Repository: "https://kubernetes-charts.storage.googleapis.com", + Name: wordpressCompName, + }, + Image: s2hv1beta1.ComponentImage{ + Repository: "bitnami/wordpress", + Pattern: "5\\.2.*debian-9.*", + }, + Source: &compSource, + Dependencies: []*s2hv1beta1.Component{ + { + Name: mariaDBCompName, + Image: s2hv1beta1.ComponentImage{ + Repository: "bitnami/mariadb", + Pattern: "10\\.3.*debian-9.*", + }, + }, + }, + Values: s2hv1beta1.ComponentValues{ + "resources": nil, + "service": map[string]interface{}{ + "type": "NodePort", + }, + "persistence": map[string]interface{}{ + "enabled": false, + }, + "mariadb": map[string]interface{}{ + "enabled": true, + "replication": map[string]interface{}{ + "enabled": false, + }, + "master": map[string]interface{}{ + "persistence": map[string]interface{}{ + "enabled": false, + }, + }, + }, + }, + } + + bundleName := "db" mockConfig := s2hv1beta1.Config{ ObjectMeta: metav1.ObjectMeta{ Name: teamName, @@ -182,14 +229,17 @@ var _ = Describe("[e2e] Staging controller", func() { }, Spec: s2hv1beta1.ConfigSpec{ Envs: map[s2hv1beta1.EnvType]s2hv1beta1.ChartValuesURLs{ + "base": map[string][]string{ + wordpressCompName: {"https://raw.githubusercontent.com/agoda-com/samsahai-example/master/envs/base/wordpress.yaml"}, + }, "staging": map[string][]string{ - "redis": {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/staging/redis.yaml"}, + redisCompName: {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/staging/redis.yaml"}, }, "pre-active": map[string][]string{ - "redis": {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/pre-active/redis.yaml"}, + redisCompName: {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/pre-active/redis.yaml"}, }, "active": map[string][]string{ - "redis": {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/active/redis.yaml"}, + redisCompName: {"https://raw.githubusercontent.com/agoda-com/samsahai/master/test/data/wordpress-redis/envs/active/redis.yaml"}, }, }, Staging: &s2hv1beta1.ConfigStaging{ @@ -203,7 +253,10 @@ var _ = Describe("[e2e] Staging controller", func() { Reporter: &s2hv1beta1.ConfigReporter{ ReportMock: true, }, - Components: []*s2hv1beta1.Component{&redisConfigComp}, + Bundles: s2hv1beta1.ConfigBundles{ + bundleName: []string{redisCompName, mariaDBCompName}, + }, + Components: []*s2hv1beta1.Component{&configCompRedis, &configCompWordpress}, }, } @@ -353,19 +406,25 @@ var _ = Describe("[e2e] Staging controller", func() { swp := stableWordPress Expect(client.Create(context.TODO(), &swp)).To(BeNil()) - By("Creating Queue") - newQueue := queue.NewUpgradeQueue(teamName, namespace, "redis", "", - s2hv1beta1.QueueComponents{{Name: "ubuntu", Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, + By("Creating 2 Queue") + redisQueue := queue.NewUpgradeQueue(teamName, namespace, bundleName, bundleName, + s2hv1beta1.QueueComponents{{Name: redisCompName, Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, + ) + mariaDBQueue := queue.NewUpgradeQueue(teamName, namespace, bundleName, bundleName, + s2hv1beta1.QueueComponents{{Name: mariaDBCompName, Repository: "bitnami/mariadb", Version: "10.3.18-debian-9-r32"}}, ) - Expect(queueCtrl.Add(newQueue)).To(BeNil()) + Expect(queueCtrl.Add(redisQueue)).To(BeNil()) + Expect(queueCtrl.Add(mariaDBQueue)).To(BeNil()) By("Deploying") err = wait.PollImmediate(2*time.Second, deployTimeout, func() (ok bool, err error) { queue := &s2hv1beta1.Queue{} - err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: newQueue.Name}, queue) + // bundle queue + err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: redisQueue.Name}, queue) if err != nil { return false, nil } + if queue.Status.IsConditionTrue(s2hv1beta1.QueueDeployStarted) { ok = true return @@ -381,17 +440,32 @@ var _ = Describe("[e2e] Staging controller", func() { Expect(err).NotTo(HaveOccurred(), "Testing error") By("Collecting") - err = wait.PollImmediate(2*time.Second, 30*time.Second, func() (ok bool, err error) { - stableComp := &s2hv1beta1.StableComponent{} - err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: newQueue.Name}, stableComp) + err = wait.PollImmediate(2*time.Second, 60*time.Second, func() (ok bool, err error) { + redisStableComp := &s2hv1beta1.StableComponent{} + err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: redisCompName}, + redisStableComp) + if err != nil { + return false, nil + } + + mariaDBStableComp := &s2hv1beta1.StableComponent{} + err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: mariaDBCompName}, + mariaDBStableComp) if err != nil { return false, nil } + ok = true return }) Expect(err).NotTo(HaveOccurred(), "Collecting error") + By("Updating Config to deploy only one component") + config = s2hv1beta1.Config{} + err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: teamName}, &config) + config.Spec.Components = []*s2hv1beta1.Component{&configCompRedis} + Expect(client.Update(context.TODO(), &config)).To(BeNil()) + By("Ensure Pre Active Components") redisServiceName := fmt.Sprintf("%s-redis-master", namespace) @@ -505,13 +579,13 @@ var _ = Describe("[e2e] Staging controller", func() { "", "", "", internal.StagingConfig{}) go stagingCtrl.Start(chStop) - redis := queue.NewUpgradeQueue(teamName, namespace, "redis", "", - s2hv1beta1.QueueComponents{{Name: "ubuntu", Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, + redis := queue.NewUpgradeQueue(teamName, namespace, redisCompName, "", + s2hv1beta1.QueueComponents{{Name: redisCompName, Repository: "bitnami/redis", Version: "5.0.5-debian-9-r160"}}, ) Expect(client.Create(context.TODO(), redis)).To(BeNil()) qhl := &s2hv1beta1.QueueHistoryList{} - err = wait.PollImmediate(1*time.Second, 60*time.Second, func() (ok bool, err error) { + err = wait.PollImmediate(1*time.Second, 120*time.Second, func() (ok bool, err error) { err = client.List(context.TODO(), qhl, &rclient.ListOptions{}) if err != nil || len(qhl.Items) < 1 { return false, nil @@ -525,7 +599,7 @@ var _ = Describe("[e2e] Staging controller", func() { err = wait.PollImmediate(2*time.Second, 60*time.Second, func() (ok bool, err error) { q := &s2hv1beta1.Queue{} - err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: "redis"}, q) + err = client.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: redisCompName}, q) if err != nil || q.Status.State != s2hv1beta1.Waiting || q.Spec.Type != s2hv1beta1.QueueTypeUpgrade { return false, nil }