gaia-pipeline / gaia

Build powerful pipelines in any programming language.
Apache License 2.0
5.2k stars 245 forks source link

Small JS error on pipeline with no jobs in Chrome #86

Closed bneil closed 6 years ago

bneil commented 6 years ago

Currently using the latest via docker run -d -p 8080:8080 -v $PWD:/data gaiapipeline/gaia:latest

After generating a pipeline (no jobs yet run), i went to the dashboard and got the following error when trying to start pipeline.

index.vue?258e:110 Uncaught TypeError: Cannot read property 'length' of undefined
    at s.checkPipelineArgs (index.vue?258e:110)
    at s.n [as checkPipelineArgs] (vue.runtime.esm.js:190)
    at click (index.vue?7896:65)
    at t (vue.runtime.esm.js:2000)
    at HTMLAnchorElement.e._withTask.e._withTask (vue.runtime.esm.js:1798)
    checkPipelineArgs () {
      // check if this pipeline has args
      for (let x = 0, y = this.pipeline.jobs.length; x < y; x++) { <--
        if (this.pipeline.jobs[x].args && this.pipeline.jobs[x].args.type !== 'vault') {
          // we found args. Redirect user to params view.
          this.$router.push({path: '/pipeline/params', query: { pipelineid: this.pipeline.id }})
          return
        }
      }

      // No args. Just start pipeline.
      this.startPipeline()
    },

this.pipeline.jobs - jobs is currently null which is causing the issue

michelvocks commented 6 years ago

Hello and welcome @bneil 🤗 Usually you see this error when your pipeline is broken or your pipeline does not expose any jobs. Gaia executes pipelines as soon as they are build (and detected) and tries to get all jobs. So by defaultthis.pipeline.jobs shouldn't be undefined.

Is there anything in the logs of Gaia? Usually this is more verbose.

Edit: Your pipeline code would also help to reproduce your problem 😄

bneil commented 6 years ago

maybe its because im just using the default golang example?

package main

import (
  "log"

  sdk "github.com/gaia-pipeline/gosdk"
)

// This is one job. Add more if you want.
func DoSomethingAwesome(args sdk.Arguments) error {
  log.Println("This output will be streamed back to gaia and will be displayed in the pipeline logs.")

  // An error occured? Return it back so gaia knows that this job failed.
  return nil
}

func main() {
  jobs := sdk.Jobs{
    sdk.Job{
      Handler:     DoSomethingAwesome,
      Title:       "DoSomethingAwesome",
      Description: "This job does something awesome.",

      // This job depends on something? Define the dependency here with the title of other jobs.
      DependsOn: []string{""},
    },
  }

  // Serve
  if err := sdk.Serve(jobs); err != nil {
    panic(err)
  }
}

which is going to exit in a panic

Logs are as follows:

2018-08-22T19:39:12.930Z [WARN ] Gaia: using auto-generated key to sign jwt tokens, do not use in production
2018-08-22T19:39:13.327Z [INFO ] Gaia: vault file doesn't exist. creating...
⇨ http server started on [::]:8080
2018-08-22T19:42:03.714Z [DEBUG] plugin: starting plugin: path=/data/pipelines/TestPipeline_golang args=[]
2018-08-22T19:42:03.719Z [DEBUG] plugin: waiting for RPC address: path=/data/pipelines/TestPipeline_golang
2018-08-22T19:42:03.746Z [DEBUG] plugin.TestPipeline_golang: panic: job 'DoSomethingAwesome' has dependency '' which is not declared
2018-08-22T19:42:03.746Z [DEBUG] plugin.TestPipeline_golang:
2018-08-22T19:42:03.747Z [DEBUG] plugin.TestPipeline_golang: goroutine 1 [running]:
2018-08-22T19:42:03.747Z [DEBUG] plugin.TestPipeline_golang: main.main()
2018-08-22T19:42:03.747Z [DEBUG] plugin.TestPipeline_golang:  /data/tmp/golang/src/6a8ecca2-cdf8-4d3a-81de-28f28072d195/test.go:31 +0x104
2018-08-22T19:42:03.747Z [DEBUG] plugin: plugin process exited: path=/data/pipelines/TestPipeline_golang
2018-08-22T19:42:03.747Z [DEBUG] Gaia: cannot connect to pipeline: error="plugin exited before we could connect" pipeline="&{1 TestPipeline {https://BNEIL@bitbucket.REDACTED.com/scm/doc/gaia-pipelines.git bneil nope {  } refs/heads/master [] /data/tmp/golang/src/6a8ecca2-cdf8-4d3a-81de-28f28072d195} golang /data/pipelines/TestPipeline_golang [95 153 137 156 178 5 50 123 168 0 59 4 149 100 40 11 139 61 107 19 123 141 63 200 234 82 0 252 50 241 90 190] [] 2018-08-22 19:42:00.8241888 +0000 UTC 6a8ecca2-cdf8-4d3a-81de-28f28072d195}"
2018-08-22T19:42:03.748Z [DEBUG] Gaia: cannot get jobs from pipeline: error="plugin exited before we could connect" pipeline="&{1 TestPipeline {https://BNEIL@bitbucket.REDACTED.com/scm/doc/gaia-pipelines.git bneil nope {  } refs/heads/master [] /data/tmp/golang/src/6a8ecca2-cdf8-4d3a-81de-28f28072d195} golang /data/pipelines/TestPipeline_golang [95 153 137 156 178 5 50 123 168 0 59 4 149 100 40 11 139 61 107 19 123 141 63 200 234 82 0 252 50 241 90 190] [] 2018-08-22 19:42:00.8241888 +0000 UTC 6a8ecca2-cdf8-4d3a-81de-28f28072d195}"
bneil commented 6 years ago

welp, if i read the error message.... this would of made more sense

panic: job 'DoSomethingAwesome' has dependency '' which is not declared

Sorry about that, closing

michelvocks commented 6 years ago

Thanks a lot @bneil . My example is actually really bad which I provided. Sorry for that I will fix that! I will also reopen this issue because we should fix the JS error when jobs is undefined.