prowjob.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package kube
  14. import (
  15. "k8s.io/test-infra/prow/apis/prowjobs/v1"
  16. )
  17. // The following are aliases to aid in the refactoring while we move
  18. // API definitions under prow/apis/
  19. // ProwJobType specifies how the job is triggered.
  20. type ProwJobType = v1.ProwJobType
  21. // ProwJobState specifies whether the job is running
  22. type ProwJobState = v1.ProwJobState
  23. // ProwJobAgent specifies the controller (such as plank or jenkins-agent) that runs the job.
  24. type ProwJobAgent = v1.ProwJobAgent
  25. // Various job types.
  26. const (
  27. // PresubmitJob means it runs on unmerged PRs.
  28. PresubmitJob = v1.PresubmitJob
  29. // PostsubmitJob means it runs on each new commit.
  30. PostsubmitJob = v1.PostsubmitJob
  31. // Periodic job means it runs on a time-basis, unrelated to git changes.
  32. PeriodicJob = v1.PeriodicJob
  33. // BatchJob tests multiple unmerged PRs at the same time.
  34. BatchJob = v1.BatchJob
  35. )
  36. // Various job states.
  37. const (
  38. // TriggeredState means the job has been created but not yet scheduled.
  39. TriggeredState = v1.TriggeredState
  40. // PendingState means the job is scheduled but not yet running.
  41. PendingState = v1.PendingState
  42. // SuccessState means the job completed without error (exit 0)
  43. SuccessState = v1.SuccessState
  44. // FailureState means the job completed with errors (exit non-zero)
  45. FailureState = v1.FailureState
  46. // AbortedState means prow killed the job early (new commit pushed, perhaps).
  47. AbortedState = v1.AbortedState
  48. // ErrorState means the job could not schedule (bad config, perhaps).
  49. ErrorState = v1.ErrorState
  50. )
  51. const (
  52. // KubernetesAgent means prow will create a pod to run this job.
  53. KubernetesAgent = v1.KubernetesAgent
  54. // JenkinsAgent means prow will schedule the job on jenkins.
  55. JenkinsAgent = v1.JenkinsAgent
  56. )
  57. const (
  58. // CreatedByProw is added on pods created by prow. We cannot
  59. // really use owner references because pods may reside on a
  60. // different namespace from the namespace parent prowjobs
  61. // live and that would cause the k8s garbage collector to
  62. // identify those prow pods as orphans and delete them
  63. // instantly.
  64. // TODO: Namespace this label.
  65. CreatedByProw = "created-by-prow"
  66. // ProwJobTypeLabel is added in pods created by prow and
  67. // carries the job type (presubmit, postsubmit, periodic, batch)
  68. // that the pod is running.
  69. ProwJobTypeLabel = "prow.k8s.io/type"
  70. // ProwJobIDLabel is added in pods created by prow and
  71. // carries the ID of the ProwJob that the pod is fulfilling.
  72. // We also name pods after the ProwJob that spawned them but
  73. // this allows for multiple resources to be linked to one
  74. // ProwJob.
  75. ProwJobIDLabel = "prow.k8s.io/id"
  76. // ProwJobAnnotation is added in pods created by prow and
  77. // carries the name of the job that the pod is running. Since
  78. // job names can be arbitrarily long, this is added as
  79. // an annotation instead of a label.
  80. ProwJobAnnotation = "prow.k8s.io/job"
  81. // OrgLabel is added in resources created by prow and
  82. // carries the org associated with the job, eg kubernetes-sigs.
  83. OrgLabel = "prow.k8s.io/refs.org"
  84. // RepoLabel is added in resources created by prow and
  85. // carries the repo associated with the job, eg test-infra
  86. RepoLabel = "prow.k8s.io/refs.repo"
  87. // PullLabel is added in resources created by prow and
  88. // carries the PR number associated with the job, eg 321.
  89. PullLabel = "prow.k8s.io/refs.pull"
  90. )
  91. // ProwJob contains the spec as well as runtime metadata.
  92. type ProwJob = v1.ProwJob
  93. // ProwJobSpec configures the details of the prow job.
  94. //
  95. // Details include the podspec, code to clone, the cluster it runs
  96. // any child jobs, concurrency limitations, etc.
  97. type ProwJobSpec = v1.ProwJobSpec
  98. // DecorationConfig specifies how to augment pods.
  99. //
  100. // This is primarily used to provide automatic integration with gubernator
  101. // and testgrid.
  102. type DecorationConfig = v1.DecorationConfig
  103. // UtilityImages holds pull specs for the utility images
  104. // to be used for a job
  105. type UtilityImages = v1.UtilityImages
  106. // PathStrategy specifies minutia about how to contruct the url.
  107. // Usually consumed by gubernator/testgrid.
  108. const (
  109. PathStrategyLegacy = v1.PathStrategyLegacy
  110. PathStrategySingle = v1.PathStrategySingle
  111. PathStrategyExplicit = v1.PathStrategyExplicit
  112. )
  113. // GCSConfiguration holds options for pushing logs and
  114. // artifacts to GCS from a job.
  115. type GCSConfiguration = v1.GCSConfiguration
  116. // ProwJobStatus provides runtime metadata, such as when it finished, whether it is running, etc.
  117. type ProwJobStatus = v1.ProwJobStatus
  118. // Pull describes a pull request at a particular point in time.
  119. type Pull = v1.Pull
  120. // Refs describes how the repo was constructed.
  121. type Refs = v1.Refs