From edbe71a7a34587612039eedb785e739d91bbc4c7 Mon Sep 17 00:00:00 2001 From: Jelmer Snoeck Date: Tue, 5 Jun 2018 13:06:50 +0200 Subject: [PATCH 1/3] Delete VersionedMicroservice in correct namespace. --- pkg/svc/controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/svc/controller.go b/pkg/svc/controller.go index 1a10dc7..cf61342 100644 --- a/pkg/svc/controller.go +++ b/pkg/svc/controller.go @@ -383,7 +383,8 @@ func deprecateReleases(cl deleteClient, crd *v1alpha1.Microservice, desired []v1 APIVersion: "hlnr.io/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{ - Name: name, + Name: name, + Namespace: crd.Namespace, }, } From a7a39f37200c321f0553b1ee96853e91f9280391 Mon Sep 17 00:00:00 2001 From: Jelmer Snoeck Date: Tue, 5 Jun 2018 13:07:09 +0200 Subject: [PATCH 2/3] Return errors accordingly. If we ignore errors that occur, the Microservice Status will get into a dirty state. We can't just ignore these. --- pkg/svc/controller.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/svc/controller.go b/pkg/svc/controller.go index cf61342..d6706d4 100644 --- a/pkg/svc/controller.go +++ b/pkg/svc/controller.go @@ -106,25 +106,19 @@ func (c *Controller) patchMicroservice(obj interface{}) error { vsvc, err := c.getVersionedMicroservice(svc, imagePolicy, &release) if err != nil { log.Printf("Error generating the VersionedMicroservice object error=%s", err) - // we don't need to return the error here, we want to be able to - // deploy other releases still - continue + return err } patch, err := c.patcher.Apply(vsvc) if err != nil { log.Printf("Error applying VersionedMicroservice error=%s", err) - // we don't need to return the error here, we want to be able to - // deploy other releases still - continue + return err } // refresh the vsvc if err := c.patcher.Get(vsvc, vsvc.Namespace, vsvc.Name); err != nil { log.Printf("Error refreshing VersionedMicroservice: %s", err) - // we don't need to return the error here, we want to be able to - // deploy other releases still - continue + return err } // Add OwnerReference to Release. We can use this later on to link to @@ -389,7 +383,7 @@ func deprecateReleases(cl deleteClient, crd *v1alpha1.Microservice, desired []v1 } if err := cl.Delete(svc); err != nil { - log.Printf("Could not delete VersionedMicroservice %s: %s", name, err) + return err } } From b22654543aee4449fc89a25f093e356fb0e00abe Mon Sep 17 00:00:00 2001 From: Jelmer Snoeck Date: Tue, 5 Jun 2018 13:20:29 +0200 Subject: [PATCH 3/3] Don't force releases to be set on status. There's a possibility that all releases for a specific ImagePolicy are deleted (no PRs for example). If we make the releases required, this would error. --- pkg/api/v1alpha1/release.go | 1 - pkg/svc/controller.go | 5 ----- 2 files changed, 6 deletions(-) diff --git a/pkg/api/v1alpha1/release.go b/pkg/api/v1alpha1/release.go index 0f9d304..1960127 100644 --- a/pkg/api/v1alpha1/release.go +++ b/pkg/api/v1alpha1/release.go @@ -105,7 +105,6 @@ func (r *SemVerRelease) fullName() string { // ReleaseValidationSchema represents the OpenAPIv3 validation schema for a // release object. var ReleaseValidationSchema = v1beta1.JSONSchemaProps{ - Required: []string{"releases"}, Properties: map[string]v1beta1.JSONSchemaProps{ "releases": { Required: []string{"semVer", "image", "released"}, diff --git a/pkg/svc/controller.go b/pkg/svc/controller.go index d6706d4..a29da2a 100644 --- a/pkg/svc/controller.go +++ b/pkg/svc/controller.go @@ -2,7 +2,6 @@ package svc import ( "context" - "errors" "log" "os" "os/signal" @@ -268,10 +267,6 @@ func (c *Controller) getImagePolicy(crd *v1alpha1.Microservice) (*v1alpha1.Image return nil, err } - if len(imagePolicy.Status.Releases) == 0 { - return nil, errors.New("Need a release to be set in the ImagePolicy Status") - } - return imagePolicy, nil }