@jwhitcraft What Rancher version (click the cow)? Is there a specific error message/code you’re getting back? I tried copying & pasting your command + substituting the relevant IDs and vars and it worked for me.
The way i test to see if it got added is to go into rancher and edit the Load Balancer Service, but I’m not seeing anything new besides the one i put in there via the api.
Is there a way to get the targets via the api? I’m not seeing it.
The normal response of adding a link is the loadBalancerService itself, so that should mean you’re getting back a 200 and it was successful. If you’re watching the UI at the same time the link should show up.
There is a consumedservices link (as in “in the links section of the loadBalancerService resource”) that will tell you the services that are linked but that returns the actual services so it doesn’t include the port mappings. To get those you currently have to go the other way, /v1/projects/1a5/serviceconsumemaps?serviceId=1s18.
The UI and rancher-compose are 100% API-driven, so if they can do it there’s a way to do it in the API… This would be an example where it’s not necessarily discoverable though.
@vincent, I figured out the problem. since i already had another mapping to that server, the addservicelink didn’t work. Once i changed to a different serviceId, the link was added.
generally, we won’t have more than one link from a lb to a service, but it’s good to know what I was doing wrong. Maybe a bug should be field for use case to kick back an error or maybe append to it, if it’s already there?
Ah, that makes sense… ports were added more recently so it’s a bug in addServiceLink to not handle the new ports or at least say 422 because that service already exists.
I don’t know of an issue for that if you’d like to add one. The UI actually only uses the set version. We’ve removed add/removeThing actions in some other places because they’re not idempotent. So our resolution might just be to drop those actions… See how set works for you?
My problem with set is, I would have to pull down all the links first just to add one. Like i said, I shouldn’t have more than one link per service so the add will work fine my use case.
Ok; @alena can we make addServiceLink and removeServiceLink handle new ports? Something like add would add the given ports if there is an array and remove would remove only the specified port if an array is given, otherwise the whole service.