Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

build-controller errors not populated on Build resource status #471

Closed
drnic opened this issue Nov 15, 2018 · 5 comments
Closed

build-controller errors not populated on Build resource status #471

drnic opened this issue Nov 15, 2018 · 5 comments
Assignees
Labels
kind/bug Something isn't working

Comments

@drnic
Copy link

drnic commented Nov 15, 2018

In creating a Build, I had forgotten to create the serviceaccount "build" referenced in the Build. This error only appears in the build-controller logs; but does not appear in the Build resource status. If errors were populated in the status of a resource, then it would make it easier to discover the issue; rather than kail -n knative-build.

The error from logs:

knative-build/build-controller-79d6cc9d57-7svtq[build-controller]: {"level":"error","logger":"controller.build-controller","caller":"build/build.go:141","msg":"Failed to validate build: serviceaccounts \"build\" not found","knative.dev/controller":"controller","knative.dev/controller":"build-controller"...

The Build resource:

apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
  creationTimestamp: 2018-11-15T01:19:32Z
  generation: 1
  name: show-me-secrets-00001
  namespace: default
  ownerReferences:
  - apiVersion: serving.knative.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Configuration
    name: show-me-secrets
    uid: 81c617d4-e874-11e8-acdf-42010a8a0072
  resourceVersion: "3245"
  selfLink: /apis/build.knative.dev/v1alpha1/namespaces/default/builds/show-me-secrets-00001
  uid: 81ca6283-e874-11e8-acdf-42010a8a0072
spec:
  generation: 1
  serviceAccountName: build
  source:
    custom:
      args:
      - -c
      - touch /tmp/SOURCE_UPLOAD_DONE; while [ -f /tmp/SOURCE_UPLOAD_DONE ]; do sleep
        1; done
      command:
      - /bin/bash
      image: ubuntu:xenial
      name: ""
      resources: {}
  template:
    arguments:
    - name: IMAGE
      value: index.docker.io/drnic/show-me-secrets
    kind: BuildTemplate
    name: buildpack
  timeout: 10m0s
status:
  completionTime: null
  startTime: null
  stepStates: null
  stepsCompleted: null
@vdemeester
Copy link
Member

/kind bug

@knative-prow-robot knative-prow-robot added the kind/bug Something isn't working label Nov 15, 2018
@ahmetb
Copy link
Contributor

ahmetb commented Nov 27, 2018

I also see this behavior on v0.2.2 (https://github.com/knative/serving/releases/download/v0.2.2/release.yaml).

If it helps, I have the service account created, but the Secret referenced by the ServiceAccount does not exist –and as you expected, no status or events are logged to the Build about this.

Repro steps, in case it helps:

  1. Create service account, but not the secret it references:
apiVersion: v1
kind: ServiceAccount
metadata:
  name: build-bot-2
secrets:
- name: does-not-exist
  1. Apply build:
apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
  name: bar
spec:
  serviceAccountName: build-bot-2
  source:
    git:
      url: https://github.com/foo/bar.git
      revision: master
  steps:
  - name: ubuntu
    image: ubuntu
    args: ["date"]
  1. Observe Build object that you applied, no events are logged, no pods are launched, no status field:
$ kubectl describe build bar
Name:         bar
Namespace:    default
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"build.knative.dev/v1alpha1","kind":"Build","metadata":{"annotations":{},"name":"bar","namespace":"default"},"spec":{"servic...
API Version:  build.knative.dev/v1alpha1
Kind:         Build
Metadata:
  Cluster Name:
  Creation Timestamp:  2018-11-27T00:43:25Z
  Generation:          1
  Resource Version:    22769317
  Self Link:           /apis/build.knative.dev/v1alpha1/namespaces/default/builds/bar
  UID:                 72fc67e0-f1dd-11e8-bd28-42010a800066
Spec: [...]
Events:     <none>
$ kubectl get build bar -o=yaml
(has no spec.status field at all)

@mathspanda
Copy link
Contributor

mathspanda commented Nov 28, 2018

Also has no status if buildtemplates not found.

Apply a service.serving without template created before:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: app-from-source
  namespace: default
spec:
  runLatest:
    configuration:
      build:
        apiVersion: build.knative.dev/v1alpha1
        kind: Build
        spec:
          source:
            git:
              url: https://github.com/mchmarny/simple-app.git
              revision: master
          template:
            name: kaniko
            arguments:
            - name: IMAGE
              value: docker.io/mathspanda/app-from-source:latest
      revisionTemplate:
        spec:
          container:
            image: docker.io/mathspanda/app-from-source:latest
            imagePullPolicy: Always
            env:
            - name: SIMPLE_MSG
              value: "Hello from the sample app!"

No status field:

root@kube-lpy:~# kubectl get build
NAME                    SUCCEEDED   REASON   STARTTIME   COMPLETIONTIME
app-from-source-00001
root@kube-lpy:~# kubectl get build -o yaml
apiVersion: v1
items:
- apiVersion: build.knative.dev/v1alpha1
  kind: Build
  metadata:
    creationTimestamp: 2018-11-28T06:28:04Z
    generation: 1
    name: app-from-source-00001
    namespace: default
    ownerReferences:
    - apiVersion: serving.knative.dev/v1alpha1
      blockOwnerDeletion: true
      controller: true
      kind: Configuration
      name: app-from-source
      uid: c2f88913-f2d6-11e8-834f-6e0a1549cb1b
    resourceVersion: "601276"
    selfLink: /apis/build.knative.dev/v1alpha1/namespaces/default/builds/app-from-source-00001
    uid: c2fa6b2a-f2d6-11e8-834f-6e0a1549cb1b
  spec:
    generation: 1
    serviceAccountName: default
    source:
      git:
        revision: master
        url: https://github.com/mchmarny/simple-app.git
    template:
      arguments:
      - name: IMAGE
        value: docker.io/mathspanda/app-from-source:latest
      kind: BuildTemplate
      name: kaniko
    timeout: 10m0s
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Only can see some info messages in logs in build-controller:

{"level":"error","logger":"controller.build-controller","caller":"controller/controller.go:271","msg":"{error 25 0  error syncing \"default/app-from-source-00001\": buildtemplates.build.knative.dev \"kaniko\" not found}","knative.dev/controller":"controller","knative.dev/controller":"build-controller"...

@mathspanda
Copy link
Contributor

May we need to setCondition and updateStatus before return err in here.

if build.Status.Cluster == nil || build.Status.Cluster.PodName == "" {
if err = c.validateBuild(build); err != nil {
logger.Errorf("Failed to validate build: %v", err)
return err
}

@vdemeester
Copy link
Member

/assign

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants