Skip to content

Commit b22b415

Browse files
committed
Bug 1737081: catsrc status should show error
Currently Status of CatalogSource does not show any information to the user on current state(s). For example, if the registry pod backed by the CatalogSource is crash looping, the status shows no information. Add the following fields to Status: - Message: It will display the error last observed. - Reason: It will display the reason, for now we have two reasons: - ConfigMapError - RegistryServerError Change the sync handler to set the error. BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1737081 Jira: https://jira.coreos.com/browse/OLM-929
1 parent 21f3b33 commit b22b415

File tree

15 files changed

+372
-119
lines changed

15 files changed

+372
-119
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $(CMDS):
7575
$(TCMDS):
7676
CGO_ENABLED=0 go test -c $(BUILD_TAGS) $(MOD_FLAGS) -o bin/$(shell basename $@) $@
7777

78-
run-local: build-linux
78+
run-local: build-linux build-wait
7979
rm -rf build
8080
. ./scripts/build_local.sh
8181
mkdir -p build/resources

pkg/api/apis/operators/catalogsource_types.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,30 @@ type RegistryServiceStatus struct {
6767
CreatedAt metav1.Time
6868
}
6969

70+
type GRPCConnectionState struct {
71+
Address string
72+
LastObservedState string
73+
LastConnectTime metav1.Time
74+
}
75+
7076
func (s *RegistryServiceStatus) Address() string {
7177
return fmt.Sprintf("%s.%s.svc.cluster.local:%s", s.ServiceName, s.ServiceNamespace, s.Port)
7278
}
7379

7480
type CatalogSourceStatus struct {
81+
Message string `json:"message,omitempty"`
82+
Reason ConditionReason `json:"reason,omitempty"`
7583
ConfigMapResource *ConfigMapResourceReference
7684
RegistryServiceStatus *RegistryServiceStatus
77-
LastSync metav1.Time
85+
GRPCConnectionState *GRPCConnectionState
7886
}
7987

8088
type ConfigMapResourceReference struct {
81-
Name string
82-
Namespace string
83-
89+
Name string
90+
Namespace string
8491
UID types.UID
8592
ResourceVersion string
93+
LastUpdateTime metav1.Time
8694
}
8795

8896
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/api/apis/operators/v1alpha1/catalogsource_types.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const (
2727
SourceTypeGrpc SourceType = "grpc"
2828
)
2929

30+
const (
31+
CatalogSourceConfigMapError ConditionReason = "ConfigMapError"
32+
CatalogSourceRegistryServerError ConditionReason = "RegistryServerError"
33+
)
34+
3035
type CatalogSourceSpec struct {
3136
// SourceType is the type of source
3237
SourceType SourceType `json:"sourceType"`
@@ -73,18 +78,35 @@ func (s *RegistryServiceStatus) Address() string {
7378
return fmt.Sprintf("%s.%s.svc.cluster.local:%s", s.ServiceName, s.ServiceNamespace, s.Port)
7479
}
7580

81+
type GRPCConnectionState struct {
82+
Address string `json:"address,omitempty"`
83+
LastObservedState string `json:"lastObservedState"`
84+
LastConnectTime metav1.Time `json:"lastConnect,omitempty"`
85+
}
86+
7687
type CatalogSourceStatus struct {
88+
// A human readable message indicating details about why the ClusterServiceVersion is in this condition.
89+
// +optional
90+
Message string `json:"message,omitempty"`
91+
// Reason is the reason the Subscription was transitioned to its current state.
92+
// +optional
93+
Reason ConditionReason `json:"reason,omitempty"`
94+
7795
ConfigMapResource *ConfigMapResourceReference `json:"configMapReference,omitempty"`
7896
RegistryServiceStatus *RegistryServiceStatus `json:"registryService,omitempty"`
79-
LastSync metav1.Time `json:"lastSync,omitempty"`
97+
GRPCConnectionState *GRPCConnectionState `json:"connectionState,omitempty"`
8098
}
8199

82100
type ConfigMapResourceReference struct {
83-
Name string `json:"name"`
84-
Namespace string `json:"namespace"`
101+
Name string `json:"name"`
102+
Namespace string `json:"namespace"`
103+
UID types.UID `json:"uid,omitempty"`
104+
ResourceVersion string `json:"resourceVersion,omitempty"`
105+
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
106+
}
85107

86-
UID types.UID `json:"uid,omitempty"`
87-
ResourceVersion string `json:"resourceVersion,omitempty"`
108+
func (r *ConfigMapResourceReference) IsAMatch(object *metav1.ObjectMeta) bool {
109+
return r.UID == object.GetUID() && r.ResourceVersion == object.GetResourceVersion()
88110
}
89111

90112
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -106,6 +128,14 @@ func (c *CatalogSource) Address() string {
106128
return c.Status.RegistryServiceStatus.Address()
107129
}
108130

131+
func (c *CatalogSource) SetError(reason ConditionReason, err error) {
132+
c.Status.Reason = reason
133+
c.Status.Message = ""
134+
if err != nil {
135+
c.Status.Message = err.Error()
136+
}
137+
}
138+
109139
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
110140

111141
// CatalogSourceList is a repository of CSVs, CRDs, and operator packages.

pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go

Lines changed: 42 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/apis/operators/v1alpha1/zz_generated.deepcopy.go

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/apis/operators/zz_generated.deepcopy.go

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)