Skip to content

Commit

Permalink
componentstatus: Reporting faulty condition for quay components (PROJ…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomaraschini committed Aug 10, 2021
1 parent 8b94d4b commit 1ae4e3e
Show file tree
Hide file tree
Showing 47 changed files with 951 additions and 0 deletions.
50 changes: 50 additions & 0 deletions apis/quay/v1/quayregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1

import (
"encoding/json"
"errors"
"os"
"strings"
Expand Down Expand Up @@ -125,6 +126,20 @@ type Condition struct {
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}

// UnhealthyComponents holds a list of unhealthy conditions in a per component basis.
type UnhealthyComponents struct {
Base []Condition `json:"base,omitempty"`
Postgres []Condition `json:"postgres,omitempty"`
Clair []Condition `json:"clair,omitempty"`
Redis []Condition `json:"redis,omitempty"`
HorizontalPodAutoscaler []Condition `json:"horizontalpodautoscaler,omitempty"`
ObjectStorage []Condition `json:"objectstorage,omitempty"`
Route []Condition `json:"route,omitempty"`
Mirror []Condition `json:"mirror,omitempty"`
Monitoring []Condition `json:"monitoring,omitempty"`
TLS []Condition `json:"tls,omitempty"`
}

// QuayRegistryStatus defines the observed state of QuayRegistry.
type QuayRegistryStatus struct {
// CurrentVersion is the actual version of Quay that is actively deployed.
Expand All @@ -140,6 +155,8 @@ type QuayRegistryStatus struct {
ConfigEditorCredentialsSecret string `json:"configEditorCredentialsSecret,omitempty"`
// Conditions represent the conditions that a QuayRegistry can have.
Conditions []Condition `json:"conditions,omitempty"`
// ComponentConditions holds the current condition for all component objects.
UnhealthyComponents UnhealthyComponents `json:"unhealthyComponents"`
}

// GetCondition retrieves the condition with the matching type from the given list.
Expand Down Expand Up @@ -330,6 +347,39 @@ func EnsureConfigEditorEndpoint(ctx *quaycontext.QuayRegistryContext, quay *Quay
return updatedQuay, quay.Status.ConfigEditorEndpoint == updatedQuay.Status.ConfigEditorEndpoint
}

// Owns verifies if a QuayRegistry object owns provided Object.
func Owns(quay QuayRegistry, obj client.Object) bool {
for _, owref := range obj.GetOwnerReferences() {
if owref.Kind != "QuayRegistry" {
continue
}
if owref.Name != quay.GetName() {
continue
}
if owref.APIVersion != GroupVersion.String() {
continue
}
if owref.UID != quay.UID {
continue
}
return true
}
return false
}

// MapToUnhealthyComponents converts a map into a UnhealthyComponents object.
func MapToUnhealthyComponents(allconds map[string][]Condition) (UnhealthyComponents, error) {
var uc UnhealthyComponents
dt, err := json.Marshal(allconds)
if err != nil {
return uc, err
}
if err := json.Unmarshal(dt, &uc); err != nil {
return uc, err
}
return uc, nil
}

// EnsureOwnerReference adds an `ownerReference` to the given object if it does not already have one.
func EnsureOwnerReference(quay *QuayRegistry, obj client.Object) (client.Object, error) {
objectMeta, err := meta.Accessor(obj)
Expand Down
86 changes: 86 additions & 0 deletions apis/quay/v1/zz_generated.deepcopy.go

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

194 changes: 194 additions & 0 deletions bundle/downstream/manifests/quayregistries.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,200 @@ spec:
status:
description: QuayRegistryStatus defines the observed state of QuayRegistry.
properties:
unhealthyComponents:
description: Component Conditions shows the conditions in a per component basis
type: object
properties:
base:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
postgres:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
clair:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
redis:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
horizontalpodautoscaler:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
objectstorage:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
route:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
mirror:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
monitoring:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
tls:
type: array
items:
type: object
properties:
lastTransitionTime:
format: date-time
type: string
lastUpdateTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
conditions:
description: Conditions represent the conditions that a QuayRegistry can have.
items:
Expand Down
Loading

0 comments on commit 1ae4e3e

Please sign in to comment.