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

Need to set content-type for certain cluster types #626

Closed
clux opened this issue Sep 1, 2021 · 3 comments · Fixed by #627
Closed

Need to set content-type for certain cluster types #626

clux opened this issue Sep 1, 2021 · 3 comments · Fixed by #627
Labels
bug Something isn't working client kube Client related

Comments

@clux
Copy link
Member

clux commented Sep 1, 2021

From reports on discord, https://agones.dev/site/ does require the content-type header set, and we are not setting it.

  • We probably need to incorporate this into a new layer or our base layer.
  • We might need to make this configurable in the future to handle protobufs

But we can work around this with tower-http middleware:

async fn build_kube_client(namespace: &str) -> Result<Client, AgonesError> {
    let config = Config::infer().await?;
    let https = config.rustls_https_connector()?;

    let service = tower::ServiceBuilder::new()
        // required setup for `kube::Client` to work
        .layer(config.base_uri_layer())
        .option_layer(config.auth_layer()?)
        // kube doesn't set `content-type: application/json` which agones requires
        .layer(SetRequestHeaderLayer::<_, Body>::if_not_present(
            http::header::CONTENT_TYPE,
            http::HeaderValue::from_static("application/json"),
        ))
        .service(hyper::Client::builder().build(https));

    Ok(Client::new(service, namespace))
}

Via discord

@clux clux added bug Something isn't working client kube Client related labels Sep 1, 2021
@nightkr
Copy link
Member

nightkr commented Sep 1, 2021

Seems like this would belong in our Request creation code, since the content-type already has semantic significance for patches?

@clux
Copy link
Member Author

clux commented Sep 1, 2021

Seems like this would belong in our Request creation code, since the content-type already has semantic significance for patches?

That is true! We can tie it to our Request by using the setters on http::Request (instead of hard-overriding it with layers) and then we tie the content type to the http api explicitly.

@kazk
Copy link
Member

kazk commented Sep 2, 2021

Opened #627

@clux clux closed this as completed in #627 Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client kube Client related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants