Coder Social home page Coder Social logo

Comments (9)

arthall avatar arthall commented on August 18, 2024

From my understanding of the docs, update_backend only updates the settings supplied with update_backend_details. It can't be used to change the change the backend_name. The API returns a header, opc-work-request-id, which can be used with get_work_request. You will probably find an error in the work request.

https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/Backend/UpdateBackend

I think update_backend_set is the API you need to change a backend server. https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/BackendSet/UpdateBackendSet

from oci-python-sdk.

adizohar avatar adizohar commented on August 18, 2024

Any update on load balancer resources will create a work-request, please check the work request if it failed or completed, you can use get_work_request(work_request_id, **kwargs) to check it

from oci-python-sdk.

sreecharanm avatar sreecharanm commented on August 18, 2024

please check my code below:


def updateBackend(lbr,backendsetname,newip):
# print(type(newTimeOutVal))
config = oci.config.from_file(file_location="~/.oci/config", profile_name="DEFAULT")
lb_cli = oci.load_balancer.LoadBalancerClient(config)
backend_dict = dict(lb_cli.get_load_balancer(lbr).data.backend_sets)
print("the dict data is ",backend_dict)
print("the ocid is",)
#print("the dict is", lb_dict)
dictlist=[]
for key, value in backend_dict.items():
temp = [key, value]
dictlist.append(temp)

for key in backend_dict.keys():
    # if key == listner :
    print("*********************")
    backends  = backend_dict[key].backends
    print(type(backends))
    print(backend_dict[key].name)
    mylist = []
    print ("the backends are",backends)
    if (len(backends)) > 0:
        for  backendietm in backends:
            print("**************")

            print("the backenditems are",backendietm)

            print("**************")
            backendset_details = oci.load_balancer.models.UpdateBackendSetDetails(policy=backend_dict[key].policy,backends=backends,health_checker=backend_dict[key].health_checker)
            print("************************************************")
            print("the abckendset_details are",backendset_details)

            print("calling update_backend_set")
            print("the backendset details are",backendset_details.backends)
            print("the backendset name",backend_dict[key].name)
            print("the lbr is",lbr)
            print("*****************")




            print("Getting the Backend Details")
            print("************************************")
            newip = "10.0.0.4:90";
            #lb_backend = lb_cli.get_backend(load_balancer_id=lbr,backend_set_name=backend_dict[key].name,backend_name="newip")
            #lb_cli.update_backend_set(update_backend_set_details=backends,load_balancer_id=lbr,backend_set_name=backend_dict[key].name)
            print("&&&&&&&&&&&&&&&&&&&&&&&")

            backenddetails = oci.load_balancer.models.UpdateBackendDetails(weight=1, backup=backendietm.backup,
                                                                           drain=backendietm.drain,
                                                                           offline=backendietm.offline)

            print("backenddetails are",backenddetails)

            print("set set set ",backend_dict[key].name)
            print("****************************")

           lb_cli.update_backend(update_backend_details=backenddetails, load_balancer_id=lbr, backend_set_name=backend_dict[key].name, backend_name=newip)

updateBackend("ocid1.loadbalancer.oc1.iad.********************","lb-20190416-****-backend-set","10.0.0.4:90")

Here I am calling the (update_backend method )

Parameters: update_backend_details (UpdateBackendDetails) -- (required) Details for updating a backend server.load_balancer_id (str) --(required) The OCID of the load balancer associated with the backend set and server.backend_set_name (str) --(required) The name of the backend set associated with the backend server.Example: example_backend_setbackend_name (str) --(required) The IP address and port of the backend server to update.Example: 10.0.0.3:8080opc_request_id (str) -- (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.opc_retry_token (str) -- (optional) A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (e.g., if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).retry_strategy (obj) --(optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.
A Response object with data of type None
Response

the O/P I am getting is:


backend set name that I am getting is : lb-20190416-****-backend-set


type of backendset {
"backends": [
{
"backup": false,
"drain": false,
"ip_address": "10.0.0.4",
"name": "10.0.0.4:80",
"offline": false,
"port": 80,
"weight": 1
}
],
"health_checker": {
"interval_in_millis": 100000,
"port": 80,
"protocol": "HTTP",
"response_body_regex": "",
"retries": 3,
"return_code": 200,
"timeout_in_millis": 3000,
"url_path": "/"
},
"policy": "ROUND_ROBIN",
"session_persistence_configuration": null,
"ssl_configuration": null
}

Process finished with exit code 0

from oci-python-sdk.

sreecharanm avatar sreecharanm commented on August 18, 2024

if I update with the same ip and port it is getting succeeded whereas if I give the new "ip" and "port" it is not getting updated. please check the below. please check the Work Requests:

Screen Shot 2019-04-24 at 12 55 03 PM

from oci-python-sdk.

arthall avatar arthall commented on August 18, 2024

Based on your code it seems like you are trying to switch one backend server for another backend server. You cannot do this with update_backend. You can only update the properties of a backend using update_backend. This is why you see the update_backend work requests succeed when you supply an IP address and port which exists in the backend set and see them fail when you supply a new IP address and port. The load balancer figures out which backend you want to update using the IP address and port. When you supply an IP address and port of a backend that is not part of the backend set the load balancer cannot perform an update_backend because it cannot find the backend to update.

You have to use update_backend_set to add or remove backends from the backend set.
https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/BackendSet/UpdateBackendSet

I think these pages may help https://docs.cloud.oracle.com/iaas/Content/Balance/Concepts/balanceoverview.htm and https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/loadbalancing.htm#Add

from oci-python-sdk.

sreecharanm avatar sreecharanm commented on August 18, 2024

Getting the backend set details:


backenddetails = oci.load_balancer.models.UpdateBackendDetails(weight=1, backup=backendietm.backup,
drain=backendietm.drain,
offline=backendietm.offline)

updating the backend details


lb_cli.update_backend(update_backend_details=backenddetails, load_balancer_id=lbr, backend_set_name=backend_dict[key].name, backend_name=backendietm.name)

As you said in the UpdateBackendDetails we don't have the property backend_name.

Here my requirement is to update the ipaddr and port. where as in the api i got the method update_backed to update the backend_name.

Correct me if i am wrong. And please let me know from which method we can update the backend_name. please let me know the flow.

from oci-python-sdk.

arthall avatar arthall commented on August 18, 2024

You cannot change the backend_name with update_backend. You need to add the new server to the backend set using update_backend_set. Backend_name is composed of the IP address and port, but it is readonly and cannot be used to set the IP address and port of a backend.

The API call you need is update_backend_set.
If you have "10.0.0.4:80" in your backend set but you want "10.0.0.5:80" you have to remove "10.0.0.4:80" and add "10.0.0.5:80" using update_backend_set. Once you have updated the backend set you will see the name "10.0.0.5:80" in your list of backends.

from oci-python-sdk.

arthall avatar arthall commented on August 18, 2024

@sreecharanm, were you able to get the backend updated?

from oci-python-sdk.

arthall avatar arthall commented on August 18, 2024

@sreecharanm, I'm going to close this ticket, assuming everything is working for you now. Please reopen it if that is not the situation.

from oci-python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.