Skip to content

Commit a89be23

Browse files
korewaChinomadonuko
andcommitted
fix an issue where the cloud node ID returns a None value
Co-authored-by: madomado <[email protected]>
1 parent 9b18534 commit a89be23

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target/
22
.env
33
Dockerfile
4+
*.log

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
/test
55

66
.env
7-
.vscode/
7+
.vscode/
8+
*.log

src/cloud/aws.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Provisioner for AWSProvisioner {
219219
public_ip,
220220
// needless conversion?
221221
// todo: Clean this up, minor performance hit
222-
instance.instance_id.map(|id| id.to_string()).as_deref(),
222+
instance.instance_id,
223223
);
224224

225225
Ok(exit_node)

src/cloud/digitalocean.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ impl Provisioner for DigitalOceanProvisioner {
135135
provisioner.clone(),
136136
name.clone(),
137137
droplet_ip.clone(),
138-
Some(&droplet_id),
138+
Some(droplet_id),
139139
);
140+
141+
debug!(?exit_node, "Created exit node!!");
140142

141143
Ok(exit_node)
142144
}

src/cloud/linode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Provisioner for LinodeProvisioner {
123123
instance_ip,
124124
instance.label,
125125
provisioner.to_string(),
126-
Some(&instance.id.to_string()),
126+
Some(instance.id.to_string()),
127127
);
128128

129129
Ok(status)

src/daemon.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use kube::{
4444
use std::{collections::BTreeMap, sync::Arc};
4545

4646
use std::time::Duration;
47-
use tracing::{debug, error, info, instrument, warn};
47+
use tracing::{debug, error, info, instrument, trace, warn};
4848

4949
use crate::{
5050
cloud::Provisioner,
@@ -479,22 +479,20 @@ fn error_policy_exit_node(
479479
Action::requeue(Duration::from_secs(5))
480480
}
481481
const UNMANAGED_PROVISIONER: &str = "unmanaged";
482+
482483
#[instrument(skip(ctx))]
483484
async fn reconcile_nodes(obj: Arc<ExitNode>, ctx: Arc<Context>) -> Result<Action, ReconcileError> {
484485
info!("exit node reconcile request: {}", obj.name_any());
485-
486486
let is_managed = check_exit_node_managed(&obj).await;
487-
488487
debug!(?is_managed, "exit node is managed by cloud provisioner?");
489-
490488
let exit_nodes: Api<ExitNode> = Api::namespaced(ctx.client.clone(), &obj.namespace().unwrap());
491489

492490
// finalizer for exit node
493-
494491
let serverside = PatchParams::apply(OPERATOR_MANAGER).validation_strict();
495492

496493
if !is_managed && obj.status.is_none() {
497494
// add status to exit node if it's not managed
495+
// This is the case for self-hosted exit nodes (Manually )
498496

499497
let nodes: Api<ExitNode> = Api::namespaced(ctx.client.clone(), &obj.namespace().unwrap());
500498

@@ -525,12 +523,14 @@ async fn reconcile_nodes(obj: Arc<ExitNode>, ctx: Arc<Context>) -> Result<Action
525523

526524
return Ok(Action::await_change());
527525
} else if is_managed {
526+
// XXX: What the fuck.
528527
let provisioner = obj
529528
.metadata
530529
.annotations
531530
.as_ref()
532531
.and_then(|annotations| annotations.get(EXIT_NODE_PROVISIONER_LABEL))
533532
.unwrap();
533+
trace!(?provisioner, "Provisioner");
534534
if let Some(status) = &obj.status {
535535
// Check for mismatch between annotation's provisioner and status' provisioner
536536
if &status.provider != provisioner {

src/ops.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,12 @@ impl ExitNodeStatus {
147147
// }
148148

149149
// It is indeed being used in cloud/*
150-
#[allow(unused_variables)]
151-
pub fn new(provider: String, name: String, ip: String, id: Option<&str>) -> Self {
150+
pub fn new(provider: String, name: String, ip: String, id: Option<String>) -> Self {
152151
Self {
153152
provider,
154153
name,
155154
ip,
156-
id: None,
155+
id,
157156
// service_binding: vec![],
158157
}
159158
}

0 commit comments

Comments
 (0)