Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-36596

REST import of eventing functions need strict checking when importing function(s) in a "paused" state.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 7.0.0
    • None
    • eventing
    • db# /opt/couchbase/bin/couchbase-server -version
      Couchbase Server 6.5.0-4632 (EE)

      cb# uname -a
      Linux couch01 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2 (2019-08-28) x86_64 GNU/Linux
    • Untriaged
    • Unknown

    Description

      REST import of eventing functions need strict checking when importing function(s) in a "paused" state. Unlike importing fucntions as deployed importing a paused function requires that the paused function a) should already exist, and b) be in a paused state.

      Take a simple Eventing function for example the attached "verifier.json" (setup for this function can be found at https://eventing-workshop.s3.amazonaws.com/Instructions.pdf )

      This works fine

      import it 

      cb# curl -X POST -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier' -d @verifier.json -H "Content-Type: application/json
      

      deploy it

      cb# curl -X POST -d '\{"deployment_status":true,"processing_status":true}' -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier/settings'
      

      wait until it is full deployed

      cb# curl -X GET -s 'http://Administrator:password@localhost:8096/api/v1/status' | grep composite_status
       "composite_status": "deploying",
      cb# curl -X GET -s 'http://Administrator:password@localhost:8096/api/v1/status' | grep composite_status
       "composite_status": "deployed",
      

      now clone the verifier.json BUT change it's name to verifier_new

      cb# sed -e 's/verifier/verifier_new/g' verifier.json > verifier_new.json
      cb# diff verifier.json verifier_new.json
      24c24
      < "appname": "verifier",
      ---
      > "appname": "verifier_new",
      

      Now deploy this new function (it was cloned from a running function, so it will also deploy)

      cb# curl -X POST -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier_new' -d @verifier_new.json -H "Content-Type: application/json"
      

      Now undeploy and delete verifier_new

      cb# curl -X POST -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier_new' -d @verifier_new.json -H "Content-Type: application/json"
      

      Wait until undeployed (just one function

      curl -X GET -s 'http://Administrator:password@localhost:8096/api/v1/status' | grep composite_status
         "composite_status": "undeployed",
         "composite_status": "deployed",
       
      cb# curl -X DELETE -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier_new'
      

      All of the above the above worked fine as expected

      The issue export / rename / import a paused function

      Now lets put the remaining function "verifier" into a paused state.

      cb# curl -X POST -d '{"deployment_status":true,"processing_status":false}' -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier/settings'
      

      Now export the function in the paused state and clone it to 'verifier_new' in file verifier_new_paused.json

      cd#  curl -X GET  -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier' --output verifier_paused.json
      cb# sed -e 's/verifier/verifier_new/g' verifier_paused.json > verifier_new_paused.json
      cb# diff verifier_paused.json verifier_new_paused.json
      24c24
      <  "appname": "verifier",
      ---
      >  "appname": "verifier_new",
      

      Now load the verifier_new function (form file verifier_new_paused.json) since it is a new function it really can not be in the paused state.

      cb# curl -X POST -s 'http://Administrator:password@localhost:8096/api/v1/functions/verifier_new' -d @verifier_new_paused.json -H "Content-Type: application/json"
      {
       "code": 0,
       "info": {
        "status": "Stored function: 'verifier_new' in metakv",
        "warnings": null
       }
      }
      

      Summary of  Issue

      Got to the UI select Eventing and refresh the page the verifier_new will be "stuck" forever in "pausing..." this is due to the fact there couldn't be a checkpoint set in appClone.settings.dcp_stream_boundary since this is a new function and it already have run and have been in a "paused" state prior to the import.

      The import logic needs to check if the Eventing/Function a) currently exists b) and is "paused" if the function is being imported into the paused state e.g.  '{"deployment_status":true,"processing_status":false}' 

      Attachments

        1. stuck_in_pausing.JPG
          28 kB
          Jon Strabala
        2. verifier_new.json
          4 kB
          Jon Strabala
        3. verifier_paused_new.json
          4 kB
          Jon Strabala
        4. verifier_paused.json
          4 kB
          Jon Strabala
        5. verifier.json
          4 kB
          Jon Strabala

        Activity

          People

            suraj.naik Suraj Naik (Inactive)
            jon.strabala Jon Strabala
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty