Skip to content

Commit

Permalink
fix: Dont fail "stacklet list" on clusters without listener-operator (#…
Browse files Browse the repository at this point in the history
…219)

* fix: Dont fail "stacklet list" on clusters without listener-operator

* changelog

* improve error handling

* move endpoints again
  • Loading branch information
sbernauer authored Mar 14, 2024
1 parent 1e59286 commit 1d95a94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions rust/stackable-cockpit/src/platform/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,19 @@ pub async fn get_endpoints(

let listeners = kube_client
.list_listeners(Some(object_namespace), &list_params)
.await
.context(KubeClientFetchSnafu)?;
.await;
let listeners = match listeners {
Ok(ok) => Ok(ok.items),
Err(k8s::Error::KubeClientFetch {
source: kube::Error::Api(err),
}) if err.code == 404 => {
// In case the listener-operator is not installed, this will return a 404. We should not fail, as this causes
// stackablectl to fail with ApiError 404 on clusters without listener-operator.
Ok(Vec::new())
}
Err(err) => Err(err),
}
.context(KubeClientFetchSnafu)?;

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

Expand Down
2 changes: 1 addition & 1 deletion rust/stackablectl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file.
### Added

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

### Changed

Expand Down

0 comments on commit 1d95a94

Please sign in to comment.