Skip to content

JSONObject["Minions"] is not a JSONArray. #146

Open

Description

@mturra-Pro

I'm using the plugin task "Send a message to Salt API" and I get this error:

hudson.remoting.ProxyException: net.sf.json.JSONException: JSONObject["Minions"] is not a JSONArray.
	at net.sf.json.JSONObject.getJSONArray(JSONObject.java:1986)
	at com.waytta.Builds.checkBlockingBuild(Builds.java:181)
	at com.waytta.SaltAPIBuilder.performRequest(SaltAPIBuilder.java:357)
	at com.waytta.SaltAPIStep$Execution.saltPerform(SaltAPIStep.java:346)
	at com.waytta.SaltAPIStep$Execution.access$300(SaltAPIStep.java:227)
	at com.waytta.SaltAPIStep$Execution$1.run(SaltAPIStep.java:264)

It not depends on function (I tried with test.ping, state.apply, ecc...).
Commands are sent and executed but jenkins doesn't understand the return (I guess)

$ salt-master --version
salt-master 3001.4
$ salt-api --version
salt-api 3001.4

Activity

  1. yukpun commented on Jun 17, 2021

    @yukpun

    I have the same issue

    Run condition [Always] enabling prebuild for step [BuilderChain]
    Run condition [Always] enabling perform for step [BuilderChain]
    Running jid: 20210616115840029581
    ERROR: Build step failed with exception
    net.sf.json.JSONException: JSONObject["Minions"] is not a JSONArray.
    	at net.sf.json.JSONObject.getJSONArray(JSONObject.java:1986)
    	at com.waytta.Builds.checkBlockingBuild(Builds.java:181)
    	at com.waytta.SaltAPIBuilder.performRequest(SaltAPIBuilder.java:357)
    	at com.waytta.SaltAPIBuilder.perform(SaltAPIBuilder.java:266)
    	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
    	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
    	at org.jenkinsci.plugins.conditionalbuildstep.BuilderChain.perform(BuilderChain.java:71)
    	at org.jenkins_ci.plugins.run_condition.BuildStepRunner$2.run(BuildStepRunner.java:112)
    	at org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail.conditionalRun(BuildStepRunner.java:156)
    	at org.jenkins_ci.plugins.run_condition.BuildStepRunner.perform(BuildStepRunner.java:107)
    	at org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder.perform(ConditionalBuilder.java:134)
    	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:21)
    	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:808)
    	at hudson.model.Build$BuildExecution.build(Build.java:199)
    	at hudson.model.Build$BuildExecution.doRun(Build.java:164)
    	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:516)
    	at hudson.model.Run.execute(Run.java:1912)
    	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    	at hudson.model.ResourceController.execute(ResourceController.java:100)
    	at hudson.model.Executor.run(Executor.java:433)
    Build step 'Conditional steps (multiple)' marked build as failure
    Finished: FAILURE
    
    Salt Version:
              Salt: 3003
    
    Dependency Versions:
              cffi: 1.12.3
          cherrypy: unknown
          dateutil: 2.6.1
         docker-py: 3.7.3
             gitdb: 2.0.3
         gitpython: 2.1.8
            Jinja2: 2.10
           libgit2: 1.1.0
          M2Crypto: Not Installed
              Mako: Not Installed
           msgpack: 0.5.6
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         pycparser: 2.19
          pycrypto: 2.6.1
      pycryptodome: 3.4.7
            pygit2: 1.5.0
            Python: 3.6.9 (default, Jan 26 2021, 15:33:00)
      python-gnupg: 0.4.1
            PyYAML: 3.12
             PyZMQ: 17.1.2
             smmap: 2.0.3
           timelib: Not Installed
           Tornado: 4.5.3
               ZMQ: 4.2.5
    
    System Versions:
              dist: ubuntu 18.04 Bionic Beaver
            locale: UTF-8
           machine: x86_64
           release: 5.0.0-27-generic
            system: Linux
           version: Ubuntu 18.04 Bionic Beaver
    
  2. yukpun commented on Jul 28, 2021

    @yukpun

    Any update on this?

  3. mchugh19 commented on Jul 29, 2021

    @mchugh19

    Sorry all. I forgot about this one after a holiday.

    Are you able to send over the debug log, as documented under "Logging Configuration
    " on https://plugins.jenkins.io/saltstack/?
    This should record what information is being submitted to the saltstack api, as well as the response.

    Thanks!

  4. yukpun commented on Jul 29, 2021

    @yukpun

    This was collected from http log

    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    ProxySelector Request for https://salt-api.domain.com:443/login
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Looking for HttpClient for URL https://salt-api.domain.com:443/login and proxy value of DIRECT
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Creating new HttpsClient with url:https://salt-api.domain.com:443/login and proxy:DIRECT with connect timeout:30000
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Proxy used: DIRECT
    Jul 29, 2021 8:00:54 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@26d4101a9 pairs: {POST /login HTTP/1.1: null}{Accept: application/json}{Content-Type: application/json}{Cache-Control: no-cache}{Pragma: no-cache}{User-Agent: Java/1.8.0_191}{Host: salt-api.domain.com}{Connection: keep-alive}{Content-Length: 61}
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    KeepAlive stream used: https://salt-api.domain.com:443/login
    Jul 29, 2021 8:00:54 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@da75bb214 pairs: {null: HTTP/1.1 200 OK}{Server: nginx/1.15.5}{Date: Thu, 29 Jul 2021 08:00:54 GMT}{Content-Type: application/json}{Content-Length: 209}{Connection: keep-alive}{Allow: GET, HEAD, POST}{Access-Control-Allow-Origin: *}{Access-Control-Expose-Headers: GET, POST}{Access-Control-Allow-Credentials: true}{X-Auth-Token: 9f8e4cacf474fa714d6ce2a42a5e853921c15e38}{Vary: Accept-Encoding}{Set-Cookie: session_id=9f8e4cacf474fa714d6ce2a42a5e853921c15e38; expires=Thu, 29 Jul 2021 18:00:54 GMT; Max-Age=36000; Path=/}{X-Upstream: 10.10.6.66:8200}
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    ProxySelector Request for https://salt-api.domain.com:443/minions
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Looking for HttpClient for URL https://salt-api.domain.com:443/minions and proxy value of DIRECT
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    KeepAlive stream retrieved from the cache, sun.net.www.protocol.https.HttpsClient(https://salt-api.domain.com:443/login)
    Jul 29, 2021 8:00:54 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Proxy used: DIRECT
    Jul 29, 2021 8:00:54 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@7c54776510 pairs: {POST /minions HTTP/1.1: null}{Accept: application/json}{Content-Type: application/json}{X-Auth-Token: 9f8e4cacf474fa714d6ce2a42a5e853921c15e38}{Cache-Control: no-cache}{Pragma: no-cache}{User-Agent: Java/1.8.0_191}{Host: salt-api.domain.com}{Connection: keep-alive}{Content-Length: 167}
    Jul 29, 2021 8:00:55 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    KeepAlive stream used: https://salt-api.domain.com:443/minions
    Jul 29, 2021 8:00:55 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@76d230a613 pairs: {null: HTTP/1.1 202 Accepted}{Server: nginx/1.15.5}{Date: Thu, 29 Jul 2021 08:00:55 GMT}{Content-Type: application/json}{Content-Length: 122}{Connection: keep-alive}{Allow: GET, HEAD, POST}{Access-Control-Allow-Origin: *}{Access-Control-Expose-Headers: GET, POST}{Access-Control-Allow-Credentials: true}{Cache-Control: private}{Vary: Accept-Encoding}{Set-Cookie: session_id=9f8e4cacf474fa714d6ce2a42a5e853921c15e38; expires=Thu, 29 Jul 2021 18:00:54 GMT; Max-Age=36000; Path=/}
    Jul 29, 2021 8:00:55 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    ProxySelector Request for https://salt-api.domain.com:443/jobs/20210729080054994964
    Jul 29, 2021 8:00:55 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Looking for HttpClient for URL https://salt-api.domain.com:443/jobs/20210729080054994964 and proxy value of DIRECT
    Jul 29, 2021 8:00:55 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    KeepAlive stream retrieved from the cache, sun.net.www.protocol.https.HttpsClient(https://salt-api.domain.com:443/minions)
    Jul 29, 2021 8:00:55 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    Proxy used: DIRECT
    Jul 29, 2021 8:00:55 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@2b2a66798 pairs: {GET /jobs/20210729080054994964 HTTP/1.1: null}{Accept: application/json}{X-Auth-Token: 9f8e4cacf474fa714d6ce2a42a5e853921c15e38}{Cache-Control: no-cache}{Pragma: no-cache}{User-Agent: Java/1.8.0_191}{Host: salt-api.domain.com}{Connection: keep-alive}
    Jul 29, 2021 8:00:56 AM FINEST sun.net.www.protocol.http.HttpURLConnection
    KeepAlive stream used: https://salt-api.domain.com:443/jobs/20210729080054994964
    Jul 29, 2021 8:00:56 AM FINE sun.net.www.protocol.http.HttpURLConnection
    sun.net.www.MessageHeader@25ed9d6c14 pairs: {null: HTTP/1.1 200 OK}{Server: nginx/1.15.5}{Date: Thu, 29 Jul 2021 08:00:56 GMT}{Content-Type: application/json}{Content-Length: 323}{Connection: keep-alive}{Allow: GET, HEAD, POST}{Access-Control-Allow-Origin: *}{Access-Control-Expose-Headers: GET, POST}{Access-Control-Allow-Credentials: true}{Cache-Control: private}{Vary: Accept-Encoding}{Set-Cookie: session_id=9f8e4cacf474fa714d6ce2a42a5e853921c15e38; expires=Thu, 29 Jul 2021 18:00:55 GMT; Max-Age=36000; Path=/}{X-Upstream: 10.10.6.66:8200}
    

    And this was collected from salt logs

    Jul 29, 2021 8:00:54 AM FINE com.waytta.saltstack
    Discovered netapi: nginx/1.15.5
    Jul 29, 2021 8:00:54 AM FINE com.waytta.saltstack
    Sending JSON: {"client":"local_async","tgt":"node-217","tgt_type":"list","fun":"state.sls","arg":"qcat_install","kwarg":{"pillar":{"version":"11.12.0.nightly614","type":"special"}}}
    
  5. yukpun commented on Aug 2, 2021

    @yukpun

    Hi @mchugh19
    Is there anything useful to understand why I git that error? I have 2 jobs in Jenkins already, which returns this error. Thanks for your help.

  6. yukpun commented on Aug 10, 2021

    @yukpun

    Kind reminder. Is there any news about this? Have no idea how to fix it

  7. mturra-Pro commented on Sep 13, 2021

    @mturra-Pro
    Author

    I took a tcp dump and I got this return value to the GET jobs/20210913145845841038 request:

    {
       "info":[
          {
             "jid":"20210913145845841038",
             "Function":"state.apply",
             "Arguments":[
                "",
                {
                   "__kwarg__":true,
                   "saltenv":"base",
                   "pillarenv":"base"
                }
             ],
             "Target":"myminion",
             "Target-type":"glob",
             "User":"admin",
             "StartTime":"2021, Sep 13 14:58:45.841038",
             "Result":{
                
             }
          }
       ],
       "return":[
          {
             
          }
       ]
    }

    In this response there are not any key "Minions" to get the array from as stated in the code in https://github.com/jenkinsci/saltstack-plugin/blob/master/src/main/java/com/waytta/Builds.java#L181.

    Is salt api response wrong or is the plugin's code?

  8. QuasiDev commented on Jan 30, 2025

    @QuasiDev

    its 2025, any development here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions