knative / build

A Kubernetes-native Build resource.
Apache License 2.0
575 stars 159 forks source link

Build step validation #605

Open johscheuer opened 5 years ago

johscheuer commented 5 years ago

Expected Behavior

I found in the knative docs the following build example:

apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
  name: example-build
spec:
  steps:
  - name: ubuntu-second
    image: ubuntu
    args: ['echo', 'hello-example', 'second']
  steps:
  - image: ubuntu
    args: ['echo', 'hello-example', 'one']

The example defines the steps multiple times (actually only two times :D), the expected behavior would be that the build is rejected because the Spec is invalid.

Actual Behavior

Only one of the two steps will be executed (the step which is defined below, at least in my 3 test runs) and the other one will be ignored. The spec actually seems to be correct: https://github.com/knative/build/blob/v0.5.0/pkg/apis/build/v1alpha1/build_types.go#L69

Steps to Reproduce the Problem

  1. Use the manifest from above
  2. Run kubectl apply -f ..
  3. Inspect the resulting build pod

Additional Info

kubectl versio
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-19T22:12:47Z", GoVersion:"go1.12.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.7-gke.10", GitCommit:"8d9b8641e72cf7c96efa61421e87f96387242ba1", GitTreeState:"clean", BuildDate:"2019-04-12T22:59:24Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}

I will try to dig into the issue and hopefully I will be able to fix this (mentoring or some hints are welcome :) )

johscheuer commented 5 years ago

This is the resulting build:

apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"build.knative.dev/v1alpha1","kind":"Build","metadata":{"annotations":{},"name":"example-build","namespace":"default"},"spec":{"steps":[{"args":["echo","hello-example","one"],"image":"ubuntu"}]}}
  creationTimestamp: "2019-05-08T18:34:07Z"
  generation: 1
  name: example-build
  namespace: default
  resourceVersion: "163654"
  selfLink: /apis/build.knative.dev/v1alpha1/namespaces/default/builds/example-build
  uid: dcfc8c4c-71bf-11e9-b521-42010aa4007f
spec:
  Status: ""
  serviceAccountName: default
  steps:
  - args:
    - echo
    - hello-example
    - one
    image: ubuntu
    name: ""
    resources: {}
  timeout: 10m0s
status:
  builder: Cluster
  cluster:
    namespace: default
    podName: example-build-pod-200876
  conditions:
  - lastTransitionTime: "2019-05-08T18:34:10Z"
    status: "True"
    type: Succeeded
  startTime: "2019-05-08T18:34:07Z"
  stepStates:
  - terminated:
      containerID: containerd://62e441b890dc7f26144b2a2efa5f6bff867bf665342dc0a1a11c7b78f8d0ae80
      exitCode: 0
      finishedAt: "2019-05-08T18:34:09Z"
      reason: Completed
      startedAt: "2019-05-08T18:34:09Z"
  stepsCompleted:
  - build-step-unnamed-0
johscheuer commented 5 years ago

I found this in the docs https://knative.dev/docs/build/builds/#steps but I don't know if this is outdated or an outlook :D