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

Commit

Permalink
Merge pull request #55 from manifoldco/delete-correct-namespace
Browse files Browse the repository at this point in the history
Handle errors and vsvc deletes properly.
  • Loading branch information
jelmersnoeck authored Jun 5, 2018
2 parents 06a2a51 + b226545 commit a15ffef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion pkg/api/v1alpha1/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
22 changes: 6 additions & 16 deletions pkg/svc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package svc

import (
"context"
"errors"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -106,25 +105,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
Expand Down Expand Up @@ -274,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
}

Expand Down Expand Up @@ -383,12 +372,13 @@ func deprecateReleases(cl deleteClient, crd *v1alpha1.Microservice, desired []v1
APIVersion: "hlnr.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Namespace: crd.Namespace,
},
}

if err := cl.Delete(svc); err != nil {
log.Printf("Could not delete VersionedMicroservice %s: %s", name, err)
return err
}
}

Expand Down

0 comments on commit a15ffef

Please sign in to comment.