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

Cannot add Kubernetes resource #116

Closed
croemmich opened this issue Mar 5, 2022 · 13 comments
Closed

Cannot add Kubernetes resource #116

croemmich opened this issue Mar 5, 2022 · 13 comments

Comments

@croemmich
Copy link

func (client *ClientImpl) AddKubernetesResource(ctx context.Context, args AddKubernetesResourceArgs) (*KubernetesResource, error) {

provides no means of supplying a serviceEndpointId. This makes it impossible to use with out receiving a 500 from the server with:

{
    "$id": "1",
    "innerException": null,
    "message": "Failed to create resource. Please ensure that all mandatory fields are provided as input.",
    "typeName": "Microsoft.TeamFoundation.DistributedTask.WebApi.KubernetesResourceException, Microsoft.TeamFoundation.DistributedTask.WebApi",
    "typeKey": "KubernetesResourceException",
    "errorCode": 0,
    "eventId": 3000
}


The AddKubernetesResourceArgs:

CreateParameters *KubernetesResourceCreateParameters

should probably take a:

type KubernetesResourceCreateParametersExistingEndpoint struct {

instead of the current:

type KubernetesResourceCreateParameters struct {

@xuzhang3
Copy link
Contributor

@nechvatalp Can you fix this SDK bug? serviceendpointId is a required parameter to create environment kubenetes resources and cannot be ignored. For API AddKubernetesResource , the args should use KubernetesResourceCreateParametersExistingEndpoint instead of KubernetesResourceCreateParameters

@theitalianz
Copy link

@croemmich / @xuzhang3 I get the same 500 if serviceEndpointId is omitted but where did you find it in the documentation?
I'm looking at https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/kubernetes/add?view=azure-devops-rest-6.0
but it is not mentioned in the request body 🤔

@xuzhang3
Copy link
Contributor

@TheItalian I get the request body by browser dev tools.

@theitalianz
Copy link

@xuzhang3 sneaky! Ok, so docs needs to be update too seems like. Gonna create an issue there as well.

@xuzhang3
Copy link
Contributor

@theitalianz I didn't test all the ways to create it, from the swagger doc there should be 3 ways to create a new environment.

@croemmich
Copy link
Author

Thanks for taking a look at this @theitalianz and @xuzhang3!

@kexugit
Copy link

kexugit commented Apr 27, 2022

@croemmich @theitalianz @xuzhang3 Please make sure swagger files are also updates - reference documents published on Docs will reflect what's defined in the swagger files.

@nechvatalp
Copy link
Collaborator

@croemmich Thanks for reporting, it actually should accept KubernetesResourceCreateParametersNewEndpoint the API accepts KubernetesResourceCreateParameters which is the baseclass of KubernetesResourceCreateParametersNewEndpoint.
However this causes generated documentation and clients to miss the crucial parameter, I filed a bug on the team owning this API to fix it.

@croemmich
Copy link
Author

croemmich commented Jul 14, 2022

@nechvatalp, @xuzhang3, I don't think KubernetesResourceCreateParametersNewEndpoint will work for our use case. We don't want to create the K8s endpoint. It's already created, we just want to associate it.

This DOES NOT work:

POST: https://dev.azure.com/{{organization}}/{{project}}/_apis/distributedtask/environments/{{envId}}/providers/kubernetes?api-version=7.1-preview.1

{"name":"test","namespace":"test","endpoint":{"id":"615631d7-2658-481f-b68e-84b6a7a2c23a"}}

Returns:

{
    "$id": "1",
    "innerException": null,
    "message": "Specified method is not supported.",
    "typeName": "System.NotSupportedException, mscorlib",
    "typeKey": "NotSupportedException",
    "errorCode": 0,
    "eventId": 0
}

This is the request body I need to make:

POST: https://dev.azure.com/{{organization}}/{{project}}/_apis/distributedtask/environments/{{envId}}/providers/kubernetes?api-version=7.1-preview.1

{"name":"test","namespace":"test","serviceEndpointId":"615631d7-2658-481f-b68e-84b6a7a2c23a"}

Of note, none of the Kubernetes Resource endpoints are documented even remotely correctly. I had to capture the network requests from the "Add resource" flow in the UI to figure out how to properly call the endpoint. The payload represented by KubernetesResourceCreateParametersNewEndpoint is never used in the UI as far as I can tell, and may not even be valid.

@venkatesh-thatham
Copy link

@nechvatalp, @theitalianz, @kexugit any update on this issue, it's remain open for the past 6 months no one seems to take any action or decision on this issue. There're more than one providers depending on this issue resolution. Appreciate your help in a timely manner.

@nechvatalp
Copy link
Collaborator

Sorry, unfortunately I don't have enough time to properly maintain this repository. It comes down to priorities I have other work which is considered higher priority. I am trying to push on our PMs and management to invest more into our API clients as I would personally love to have them properly taken care of but so far, I was unsuccessful.

@nechvatalp
Copy link
Collaborator

Attempted to fix this issue in the upcoming 7.1 release.

I split the method in two
AddKubernetesResourceNewEndpoint accepting the AddKubernetesResourceArgsNewEndpoint
AddKubernetesResourcExistingEndpoint accepting the AddKubernetesResourceArgsExistingEndpoint

I don't have any environment to test it but I guess I can't make it worse.

Commit with the change f4a4ff5

@nechvatalp
Copy link
Collaborator

This should be fixed in the latest 7.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants