Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matcher #431

Merged
merged 9 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tembo-operator/src/app_service/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub fn generate_ingress_tcp_routes(
continue;
}

let matcher = format!("{host_matcher} && PathPrefix(`{}`)", path);
let matcher = format!("HostSNI(`{}`)", host_matcher);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to update some assertions in the functional_test_app_service integration test

let middlewares: Option<Vec<IngressRouteTCPRoutesMiddlewares>> =
route.middlewares.clone().map(|names| {
names
Expand Down Expand Up @@ -398,9 +398,10 @@ pub async fn reconcile_ingress_tcp(
desired_routes: Vec<IngressRouteTCPRoutes>,
desired_middlewares: Vec<Middleware>,
entry_points_tcp: Vec<String>,
app_name: &str,
) -> Result<(), kube::Error> {
let ingress_api: Api<IngressRouteTCP> = Api::namespaced(client.clone(), ns);
let name = format!("{}-apps", coredb_name);
let name = format!("{}-{}", coredb_name, app_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌


let middleware_api: Api<TraefikMiddleware> = Api::namespaced(client.clone(), ns);
let desired_middlewares = generate_middlewares(&name, ns, oref.clone(), desired_middlewares);
Expand Down
49 changes: 28 additions & 21 deletions tembo-operator/src/app_service/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ pub async fn reconcile_app_services(cdb: &CoreDB, ctx: Arc<Context>) -> Result<(
"localhost".to_string()
}
};

// Iterate over each AppService and process routes

let resources: Vec<AppServiceResources> = appsvcs
.iter()
.map(|appsvc| generate_resource(appsvc, &coredb_name, &ns, oref.clone(), domain.to_owned()))
Expand Down Expand Up @@ -692,29 +695,33 @@ pub async fn reconcile_app_services(cdb: &CoreDB, ctx: Arc<Context>) -> Result<(
}
}

match reconcile_ingress_tcp(
client.clone(),
&coredb_name,
&ns,
oref.clone(),
desired_tcp_routes,
desired_middlewares,
desired_entry_points_tcp,
)
.await
{
Ok(_) => {
debug!("Updated/applied IngressRouteTCP for {}.{}", ns, coredb_name,);
}
Err(e) => {
error!(
"Failed to update/apply IngressRouteTCP {}.{}: {}",
ns, coredb_name, e
);
has_errors = true;
for appsvc in appsvcs.iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up, let's make sure the expected IngressRouteTCP resources are created when we have multiple apps that use IngressType: tcp

let app_name = appsvc.name.clone();

match reconcile_ingress_tcp(
client.clone(),
&coredb_name,
&ns,
oref.clone(),
desired_tcp_routes.clone(),
desired_middlewares.clone(),
desired_entry_points_tcp.clone(),
&app_name,
)
.await
{
Ok(_) => {
debug!("Updated/applied IngressRouteTCP for {}.{}", ns, coredb_name,);
}
Err(e) => {
error!(
"Failed to update/apply IngressRouteTCP {}.{}: {}",
ns, coredb_name, e
);
has_errors = true;
}
}
}

if has_errors || apply_errored {
return Err(Action::requeue(Duration::from_secs(300)));
}
Expand Down
Loading