Skip to content

Commit

Permalink
fix(kubectl/dump/etcd): use correct namespace
Browse files Browse the repository at this point in the history
When we run outside of the cluster, we can't just use the env to determine
the correct namespace..
A better solution is perhaps to simply ensure we create clients with the
correct namespace as default?

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Mar 16, 2024
1 parent 67c12dd commit fdef22a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions k8s/supportability/src/collect/k8s_resources/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ impl ClientSet {
pub(crate) fn kube_client(&self) -> kube::Client {
self.client.clone()
}
/// Get a reference to the namespace.
pub(crate) fn namespace(&self) -> &str {
&self.namespace
}

/// Get a new api for a `dynamic_object` for the provided GVK.
pub(crate) async fn dynamic_object_api(
Expand Down
7 changes: 4 additions & 3 deletions k8s/supportability/src/collect/persistent_store/etcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ impl EtcdStore {
namespace: String,
) -> Result<Self, EtcdError> {
let client_set = ClientSet::new(kube_config_path.clone(), namespace.clone()).await?;
let platform_info = platform::k8s::K8s::from(client_set.kube_client())
.await
.map_err(|e| EtcdError::Custom(format!("Failed to get k8s platform info: {e}")))?;
let platform_info =
platform::k8s::K8s::from_custom(client_set.kube_client(), client_set.namespace())
.await
.map_err(|e| EtcdError::Custom(format!("Failed to get k8s platform info: {e}")))?;
let key_prefix = pstor::build_key_prefix(&platform_info, API_VERSION);

// if an endpoint is provided it will be used, else the kubeconfig path will be used
Expand Down

0 comments on commit fdef22a

Please sign in to comment.