Skip to content

Commit 1d95a94

Browse files
authored
fix: Dont fail "stacklet list" on clusters without listener-operator (#219)
* fix: Dont fail "stacklet list" on clusters without listener-operator * changelog * improve error handling * move endpoints again
1 parent 1e59286 commit 1d95a94

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

rust/stackable-cockpit/src/platform/service.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,19 @@ pub async fn get_endpoints(
5050

5151
let listeners = kube_client
5252
.list_listeners(Some(object_namespace), &list_params)
53-
.await
54-
.context(KubeClientFetchSnafu)?;
53+
.await;
54+
let listeners = match listeners {
55+
Ok(ok) => Ok(ok.items),
56+
Err(k8s::Error::KubeClientFetch {
57+
source: kube::Error::Api(err),
58+
}) if err.code == 404 => {
59+
// In case the listener-operator is not installed, this will return a 404. We should not fail, as this causes
60+
// stackablectl to fail with ApiError 404 on clusters without listener-operator.
61+
Ok(Vec::new())
62+
}
63+
Err(err) => Err(err),
64+
}
65+
.context(KubeClientFetchSnafu)?;
5566

5667
let mut endpoints = IndexMap::new();
5768
for listener in &listeners {
@@ -77,7 +88,7 @@ pub async fn get_endpoints(
7788
// find Listeners is currently not required. However, once we add the recommended labels to the k8s Services, we
7889
// would have duplicated entries (one from the Listener and one from the Service). Because of this we don't look at
7990
// the Services in case we found Listeners!
80-
if !listeners.items.is_empty() {
91+
if !listeners.is_empty() {
8192
return Ok(endpoints);
8293
}
8394

rust/stackablectl/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file.
77
### Added
88

99
- Support listing endpoints of Listeners in `stackablectl stacklet list` command.
10-
Currently only HDFS is using listener-op, so we can only test that so far ([#213]).
10+
Currently only HDFS is using listener-op, so we can only test that so far ([#213], [#219]).
1111

1212
### Changed
1313

0 commit comments

Comments
 (0)