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 #54 from manifoldco/better-sync-behaviour
Browse files Browse the repository at this point in the history
Correct syncing behaviour
  • Loading branch information
jelmersnoeck authored Jun 5, 2018
2 parents a15ffef + 960a442 commit 839c2ab
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 95 deletions.
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions pkg/githubrepository/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import (
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)

func init() {
// let's not hit rate limits
kubekit.ResyncPeriod = 30 * time.Second
}

// Controller will take care of syncing the internal status of the GitHub Policy
// object with the available releases on GitHub.
type Controller struct {
Expand Down Expand Up @@ -58,6 +53,11 @@ const authTokenKey = "GITHUB_AUTH_TOKEN"

// NewController returns a new GitHubRepository Controller.
func NewController(rcfg *rest.Config, cs kubernetes.Interface, namespace string, cfg Config) (*Controller, error) {
// Let's not hit rate limits.
// This is done here instead of an init function so we don't override the
// global settings for other controllers.
kubekit.ResyncPeriod = 30 * time.Second

rc, err := kubekit.RESTClient(rcfg, &v1alpha1.SchemeGroupVersion, v1alpha1.AddToScheme)
if err != nil {
return nil, err
Expand Down Expand Up @@ -117,9 +117,7 @@ func (c *Controller) run(ctx context.Context) {
c.syncPolicy(obj)
},
UpdateFunc: func(old, new interface{}) {
if ok, err := k8sutils.ShouldSync(old, new); ok && err == nil {
c.syncPolicy(new)
}
c.syncPolicy(new)
},
DeleteFunc: func(obj interface{}) {
cp := obj.(*v1alpha1.GitHubRepository).DeepCopy()
Expand Down
5 changes: 1 addition & 4 deletions pkg/imagepolicy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"syscall"

"github.com/manifoldco/heighliner/pkg/api/v1alpha1"
"github.com/manifoldco/heighliner/pkg/k8sutils"
"github.com/manifoldco/heighliner/pkg/registry"
"github.com/manifoldco/heighliner/pkg/registry/hub"

Expand Down Expand Up @@ -95,9 +94,7 @@ func (c *Controller) run(ctx context.Context) {
c.syncPolicy(obj)
},
UpdateFunc: func(old, new interface{}) {
if ok, err := k8sutils.ShouldSync(old, new); ok && err == nil {
c.syncPolicy(new)
}
c.syncPolicy(new)
},
DeleteFunc: func(obj interface{}) {
cp := obj.(*v1alpha1.ImagePolicy).DeepCopy()
Expand Down
66 changes: 0 additions & 66 deletions pkg/k8sutils/status.go

This file was deleted.

11 changes: 1 addition & 10 deletions pkg/networkpolicy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"syscall"

"github.com/manifoldco/heighliner/pkg/api/v1alpha1"
"github.com/manifoldco/heighliner/pkg/k8sutils"

"github.com/jelmersnoeck/kubekit"
"github.com/jelmersnoeck/kubekit/patcher"
Expand Down Expand Up @@ -76,15 +75,7 @@ func (c *Controller) run(ctx context.Context) {
c.syncNetworking(obj)
},
UpdateFunc: func(old, new interface{}) {
ok, err := k8sutils.ShouldSync(old, new)
if err != nil {
cp := old.(*v1alpha1.NetworkPolicy).DeepCopy()
log.Printf("Error syncing networkpolicy %s: %s:", cp.Name, err)
}

if ok {
c.syncNetworking(new)
}
c.syncNetworking(new)
},
DeleteFunc: func(obj interface{}) {
cp := obj.(*v1alpha1.NetworkPolicy).DeepCopy()
Expand Down
5 changes: 2 additions & 3 deletions pkg/svc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func (c *Controller) run(ctx context.Context) {
c.patchMicroservice(obj)
},
UpdateFunc: func(old, new interface{}) {
if ok, err := k8sutils.ShouldSync(old, new); ok && err == nil {
c.patchMicroservice(new)
}
c.patchMicroservice(new)
},
DeleteFunc: func(obj interface{}) {
svc := obj.(*v1alpha1.Microservice).DeepCopy()
Expand Down Expand Up @@ -146,6 +144,7 @@ func (c *Controller) patchMicroservice(obj interface{}) error {

// new release objects, store them
svc.Status.Releases = deployedReleases

// need to specify types again until we resolve the mapping issue
svc.TypeMeta = metav1.TypeMeta{
Kind: "Microservice",
Expand Down

0 comments on commit 839c2ab

Please sign in to comment.