Skip to content

Commit aa1fc6c

Browse files
Merge pull request #974 from tkashem/catsrc-status
Bug 1737081: catsrc status should show error
2 parents 9cb8d1e + b22b415 commit aa1fc6c

29 files changed

+1705
-267
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,19 @@ build-linux: build_cmd=build
6464
build-linux: arch_flags=GOOS=linux GOARCH=386
6565
build-linux: clean $(CMDS)
6666

67+
build-wait: clean bin/wait
68+
69+
bin/wait:
70+
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -o $@ $(PKG)/test/e2e/wait
71+
6772
$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=$(GIT_COMMIT) -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
6873
$(CMDS):
6974
CGO_ENABLED=0 $(arch_flags) go $(build_cmd) $(MOD_FLAGS) $(version_flags) -o bin/$(shell basename $@) $@
7075

7176
$(TCMDS):
7277
CGO_ENABLED=0 go test -c $(BUILD_TAGS) $(MOD_FLAGS) -o bin/$(shell basename $@) $@
7378

74-
run-local: build-linux
79+
run-local: build-linux build-wait
7580
rm -rf build
7681
. ./scripts/build_local.sh
7782
mkdir -p build/resources
@@ -95,9 +100,9 @@ setup-bare: clean e2e.namespace
95100
. ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources
96101

97102
e2e:
98-
go test -v $(MOD_FLAGS) -failfast -timeout 70m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager
103+
go test -v $(MOD_FLAGS) -failfast -timeout 70m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager -dummyImage=bitnami/nginx:latest
99104

100-
e2e-local: build-linux
105+
e2e-local: build-linux build-wait
101106
. ./scripts/build_local.sh
102107
. ./scripts/run_e2e_local.sh $(TEST)
103108

cmd/olm/cleanup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func cleanup(logger *logrus.Logger, c operatorclient.ClientInterface, crc versio
3737
logger.WithError(err).Fatal("couldn't clean previous release")
3838
}
3939

40+
if err := waitForDelete(checkClusterServiceVersion(crc, "packageserver.v0.10.1"), deleteClusterServiceVersion(crc, "packageserver.v0.10.0")); err != nil {
41+
logger.WithError(err).Fatal("couldn't clean previous release")
42+
}
43+
4044
if err := waitForDelete(checkClusterServiceVersion(crc, "packageserver.v0.9.0"), deleteClusterServiceVersion(crc, "packageserver.v0.9.0")); err != nil {
4145
logger.WithError(err).Fatal("couldn't clean previous release")
4246
}

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)