Skip to content

Commit c0b8261

Browse files
authored
Merge pull request #136 from Jakob-Naucke/cluster-count-msg
register-server: Fix cluster count error message
2 parents 77ef33b + 6da1153 commit c0b8261

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

register-server/src/main.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ async fn get_public_trustee_addr(client: Client) -> anyhow::Result<String> {
8383
let clusters: Api<TrustedExecutionCluster> = Api::default_namespaced(client);
8484
let params = Default::default();
8585
let mut list = clusters.list(&params).await?;
86-
if list.items.len() != 1 {
86+
if list.items.is_empty() {
87+
return Err(anyhow!(
88+
"No TrustedExecutionCluster found in namespace {namespace}. \
89+
Ensure that this register-server is in the same namespace \
90+
as the TrustedExecutionCluster you're targeting.
91+
Cancelling Ignition Clevis PIN request.",
92+
));
93+
} else if list.items.len() > 1 {
8794
return Err(anyhow!(
8895
"More than one TrustedExecutionCluster found in namespace {namespace}. \
8996
trusted-cluster-operator does not support more than one TrustedExecutionCluster. \
@@ -212,6 +219,19 @@ mod tests {
212219
});
213220
}
214221

222+
#[tokio::test]
223+
async fn test_get_public_trustee_addr_none() {
224+
let clos = async |_, _| {
225+
let mut clusters = dummy_clusters();
226+
clusters.items.clear();
227+
Ok(serde_json::to_string(&clusters).unwrap())
228+
};
229+
count_check!(1, clos, |client| {
230+
let err = get_public_trustee_addr(client).await.err().unwrap();
231+
assert!(err.to_string().contains("No TrustedExecutionCluster found"));
232+
});
233+
}
234+
215235
#[tokio::test]
216236
async fn test_get_public_trustee_addr_multiple() {
217237
let clos = async |_, _| {

0 commit comments

Comments
 (0)