Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1012 from marun/fix-cluster-scoped-ftc
Browse files Browse the repository at this point in the history
Ensure cluster scoped sync controller starts without namespace ftc
  • Loading branch information
k8s-ci-robot authored Jun 24, 2019
2 parents 84e6d3c + 0750db2 commit d188d22
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pkg/controller/federatedtypeconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,25 @@ func (c *Controller) startSyncController(tc *corev1b1.FederatedTypeConfig) error
// cluster-scoped KubeFed control plane. A namespace-scoped
// control plane would still have to use a non-shared informer due
// to it not being possible to limit its scope.

ftc := tc.DeepCopyObject().(*corev1b1.FederatedTypeConfig)
kind := tc.Spec.FederatedType.Kind
fedNamespaceAPIResource, err := c.getFederatedNamespaceAPIResource()
if err != nil {
return errors.Wrapf(err, "Unable to start sync controller for %q due to missing FederatedTypeConfig for namespaces", kind)

// A sync controller for a namespaced resource must be supplied
// with the ftc for namespaces so that it can consider federated
// namespace placement when determining the placement for
// contained resources.
var fedNamespaceAPIResource *metav1.APIResource
if ftc.GetNamespaced() {
var err error
fedNamespaceAPIResource, err = c.getFederatedNamespaceAPIResource()
if err != nil {
return errors.Wrapf(err, "Unable to start sync controller for %q due to missing FederatedTypeConfig for namespaces", kind)
}
}

stopChan := make(chan struct{})
ftc := tc.DeepCopyObject().(*corev1b1.FederatedTypeConfig)
err = synccontroller.StartKubeFedSyncController(c.controllerConfig, stopChan, ftc, fedNamespaceAPIResource)
err := synccontroller.StartKubeFedSyncController(c.controllerConfig, stopChan, ftc, fedNamespaceAPIResource)
if err != nil {
close(stopChan)
return errors.Wrapf(err, "Error starting sync controller for %q", kind)
Expand Down Expand Up @@ -375,9 +386,6 @@ func (c *Controller) namespaceFTCExists() bool {
}

func (c *Controller) getFederatedNamespaceAPIResource() (*metav1.APIResource, error) {
c.lock.Lock()
defer c.lock.Unlock()

qualifiedName := util.QualifiedName{
Namespace: c.controllerConfig.KubeFedNamespace,
Name: util.NamespaceName,
Expand Down

0 comments on commit d188d22

Please sign in to comment.