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

Admission controller doesn't send message to api-server? #494

Closed
SachinMaharana opened this issue Apr 16, 2021 · 1 comment · Fixed by #498
Closed

Admission controller doesn't send message to api-server? #494

SachinMaharana opened this issue Apr 16, 2021 · 1 comment · Fixed by #498
Labels
api Api abstraction related bug Something isn't working

Comments

@SachinMaharana
Copy link
Contributor

SachinMaharana commented Apr 16, 2021

Hi. I am using kube-rs to write a mutating admission controller. I am seeing certain issue which i intend to highligh here.
Here's a sinppet i am working with.

fn admission_error(req: AdmissionRequest<DynamicObject>, err: anyhow::Error, code: i32) -> HttpResponse {

    error!("error in admission: {}", err.to_string());
    let mut resp = AdmissionResponse::from(&req);
    resp.result = Status {
        code: Some(code),
        message: Some("Can i see this message?".to_string()),
        reason: Some(err.to_string()),
        ..Default::default()
    };
    resp.allowed = false;
    HttpResponse::Ok().json(resp.into_review())
}

Here i see the controller is working as expected with the following log.
ERROR image_tag_constraint_controller: error in admission: error with request namespace. cannot inject pod into system ns kube-system.

But i don't see the message/reason for this in the describe resource(replicaSet).

Warning  FailedCreate  2s (x12 over 12s)  replicaset-controller  Error creating: admission webhook "image-tag-constraint-controll er.default.svc.cluster.local" denied the request without explanation

Error From API Server:

W0419 07:02:30.018105       1 dispatcher.go:142] rejected by webhook "image-tag-constraint-controll er.default.svc.cluster.local": &errors.StatusError{ErrStatus:v1.Status{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ListMeta:v1.ListMeta{SelfLink:"", ResourceVersion:"", Continue:"", RemainingItemCount:(*int64)(nil)}, Status:"Failure", Message:"admission webhook \"basic-validation-controller.default.svc.cluster.local\" denied the request without explanation", Reason:"", Details:(*v1.StatusDetails)(nil), Code:400}}

Here i expected to see the message why this was denied. I noticed i couldn't find the logs in the api-server as well.

Am i missing something here?

@SachinMaharana SachinMaharana changed the title Admission controller doesn't send message to client? Admission controller doesn't send message to api-server? Apr 17, 2021
@clux clux added api Api abstraction related bug Something isn't working labels Apr 19, 2021
@clux
Copy link
Member

clux commented Apr 19, 2021

Thanks for trying out admission controller stuff so early before we have released it properly!

This could be a bug. I was hoping that err/reason was going to be used here, but looks like it doesn't.
Although from the response documentation reference it looks like we are doing the right thing.

There is also a warnings field from kubernetes 1.19, but that doesn't feel like it should be where you put a deny-reason. Does that end up there?

Was hoping to do a cleanup and full documented setup of this myself before making a minor version for admission + ResourceExt anyway, so this is another thing to look at. Hopefully will have time later. Thanks for the report.

SachinMaharana added a commit to SachinMaharana/kube-rs that referenced this issue Apr 19, 2021
@clux clux closed this as completed in #498 Apr 19, 2021
clux added a commit that referenced this issue Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Api abstraction related bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants