This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 9973bc710279234d56c06d00720fee9d902fa42c
Author: Antonin Stefanutti <[email protected]>
AuthorDate: Mon Jun 29 18:08:07 2020 +0200

    fix(crd): metav1.Time fails CRD validation
    
    See https://github.com/kubernetes/kubernetes/issues/86811
---
 deploy/crd-build.yaml                                   |  1 -
 .../1.1.0-snapshot/builds.camel.apache.org.crd.yaml     |  1 -
 deploy/resources.go                                     |  4 ++--
 helm/camel-k/crds/crd-build.yaml                        |  1 -
 pkg/apis/camel/v1/build_types.go                        | 17 ++++++++---------
 pkg/apis/camel/v1/zz_generated.deepcopy.go              |  5 ++++-
 pkg/controller/build/monitor_pod.go                     |  5 +++--
 pkg/controller/build/schedule_routine.go                |  3 ++-
 8 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/deploy/crd-build.yaml b/deploy/crd-build.yaml
index c366e91..27ad6f3 100644
--- a/deploy/crd-build.yaml
+++ b/deploy/crd-build.yaml
@@ -4610,7 +4610,6 @@ spec:
               type: string
             startedAt:
               format: date-time
-              nullable: true
               type: string
           type: object
       type: object
diff --git 
a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/builds.camel.apache.org.crd.yaml
 
b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/builds.camel.apache.org.crd.yaml
index c366e91..27ad6f3 100644
--- 
a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/builds.camel.apache.org.crd.yaml
+++ 
b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/builds.camel.apache.org.crd.yaml
@@ -4610,7 +4610,6 @@ spec:
               type: string
             startedAt:
               format: date-time
-              nullable: true
               type: string
           type: object
       type: object
diff --git a/deploy/resources.go b/deploy/resources.go
index 4d522a8..8909f03 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -112,9 +112,9 @@ var assets = func() http.FileSystem {
                "/crd-build.yaml": &vfsgen۰CompressedFileInfo{
                        name:             "crd-build.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 301768,
+                       uncompressedSize: 301739,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xbd\x6b\x73\x23\xb7\xb5\x28\xfa\xdd\xbf\x02\x25\xa7\x4a\xd2\x8e\x48\x79\xf6\xce\xcd\xce\x9e\xec\x8a\x4b\x1e\x69\x1c\x5d\xcf\x43\x67\xa8\xb1\xef\x29\x27\x3b\x05\x76\x83\x24\xa2\x6e\xa0\x0d\xa0\xa5\x61\x8e\xcf\x7f\xbf\x85\x05\xa0\x1f\x7c\xf5\x42\x93\xd2\xc8\x76\xe3\xcb\x8c\x48\xf6\x6a\x3c\x16\xd6\xfb\xf1\x25\x19\x1d\x6e\x7c\xf1\x25\x79\xc3\x13\x26\x34\x4b\x89\x91\xc4\x2c\x18\xb9\x28\x68\xb2\x60\x64\x22\x67\xe6\x81\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xbd\x6b\x73\x23\xb7\xb5\x28\xfa\xdd\xbf\x02\x25\xa7\x4a\xd2\x8e\x48\x79\xf6\xce\xcd\xce\x9e\xec\x8a\x4b\x1e\x69\x1c\x5d\xcf\x43\x67\xa8\xb1\xef\x29\x27\x3b\x05\x76\x83\x24\xa2\x6e\xa0\x0d\xa0\xa5\x61\x8e\xcf\x7f\xbf\x85\x05\xa0\x1f\x7c\xf5\x42\x93\xd2\xc8\x76\xe3\xcb\x8c\x48\xf6\x6a\x3c\x16\xd6\xfb\xf1\x25\x19\x1d\x6e\x7c\xf1\x25\x79\xc3\x13\x26\x34\x4b\x89\x91\xc4\x2c\x18\xb9\x28\x68\xb2\x60\x64\x22\x67\xe6\x81\x
 [...]
                },
                "/crd-camel-catalog.yaml": &vfsgen۰CompressedFileInfo{
                        name:             "crd-camel-catalog.yaml",
diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml
index c366e91..27ad6f3 100644
--- a/helm/camel-k/crds/crd-build.yaml
+++ b/helm/camel-k/crds/crd-build.yaml
@@ -4610,7 +4610,6 @@ spec:
               type: string
             startedAt:
               format: date-time
-              nullable: true
               type: string
           type: object
       type: object
diff --git a/pkg/apis/camel/v1/build_types.go b/pkg/apis/camel/v1/build_types.go
index 9311965..6b9c3d7 100644
--- a/pkg/apis/camel/v1/build_types.go
+++ b/pkg/apis/camel/v1/build_types.go
@@ -84,15 +84,14 @@ type BuilderTask struct {
 
 // BuildStatus defines the observed state of Build
 type BuildStatus struct {
-       Phase     BuildPhase `json:"phase,omitempty"`
-       Image     string     `json:"image,omitempty"`
-       Digest    string     `json:"digest,omitempty"`
-       BaseImage string     `json:"baseImage,omitempty"`
-       Artifacts []Artifact `json:"artifacts,omitempty"`
-       Error     string     `json:"error,omitempty"`
-       Failure   *Failure   `json:"failure,omitempty"`
-       // +nullable
-       StartedAt  metav1.Time      `json:"startedAt,omitempty"`
+       Phase      BuildPhase       `json:"phase,omitempty"`
+       Image      string           `json:"image,omitempty"`
+       Digest     string           `json:"digest,omitempty"`
+       BaseImage  string           `json:"baseImage,omitempty"`
+       Artifacts  []Artifact       `json:"artifacts,omitempty"`
+       Error      string           `json:"error,omitempty"`
+       Failure    *Failure         `json:"failure,omitempty"`
+       StartedAt  *metav1.Time     `json:"startedAt,omitempty"`
        Platform   string           `json:"platform,omitempty"`
        Conditions []BuildCondition `json:"conditions,omitempty"`
        // Change to Duration / ISO 8601 when CRD uses OpenAPI spec v3
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go 
b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 87f7ff9..3cd5a5f 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -176,7 +176,10 @@ func (in *BuildStatus) DeepCopyInto(out *BuildStatus) {
                *out = new(Failure)
                (*in).DeepCopyInto(*out)
        }
-       in.StartedAt.DeepCopyInto(&out.StartedAt)
+       if in.StartedAt != nil {
+               in, out := &in.StartedAt, &out.StartedAt
+               *out = (*in).DeepCopy()
+       }
        if in.Conditions != nil {
                in, out := &in.Conditions, &out.Conditions
                *out = make([]BuildCondition, len(*in))
diff --git a/pkg/controller/build/monitor_pod.go 
b/pkg/controller/build/monitor_pod.go
index 44c13c2..cd6aca1 100644
--- a/pkg/controller/build/monitor_pod.go
+++ b/pkg/controller/build/monitor_pod.go
@@ -60,8 +60,9 @@ func (action *monitorPodAction) Handle(ctx context.Context, 
build *v1.Build) (*v
        case pod.Status.Phase == corev1.PodPending && 
action.isPodScheduled(pod),
                pod.Status.Phase == corev1.PodRunning:
                build.Status.Phase = v1.BuildPhaseRunning
-               if build.Status.StartedAt.Time.IsZero() {
-                       build.Status.StartedAt = metav1.Now()
+               if build.Status.StartedAt == nil || 
build.Status.StartedAt.Time.IsZero() {
+                       now := metav1.Now()
+                       build.Status.StartedAt = &now
                }
 
        case pod.Status.Phase == corev1.PodSucceeded:
diff --git a/pkg/controller/build/schedule_routine.go 
b/pkg/controller/build/schedule_routine.go
index db66bb2..6edc0f7 100644
--- a/pkg/controller/build/schedule_routine.go
+++ b/pkg/controller/build/schedule_routine.go
@@ -103,9 +103,10 @@ func (action *scheduleRoutineAction) Handle(ctx 
context.Context, build *v1.Build
 func (action *scheduleRoutineAction) runBuild(ctx context.Context, build 
*v1.Build) {
        defer action.routines.Delete(build.Name)
 
+       now := metav1.Now()
        status := v1.BuildStatus{
                Phase:     v1.BuildPhaseRunning,
-               StartedAt: metav1.Now(),
+               StartedAt: &now,
        }
        if err := action.updateBuildStatus(ctx, build, status); err != nil {
                return

Reply via email to