Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ COPY . .
RUN NO_DOCKER=1 make build

FROM registry.svc.ci.openshift.org/openshift/origin-v4.0:base
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/owned-manifests owned-manifests
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/install manifests
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/bin/machine-api-operator .
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/bin/nodelink-controller .
Expand Down
1 change: 0 additions & 1 deletion Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ COPY . .
RUN NO_DOCKER=1 make build

FROM registry.svc.ci.openshift.org/ocp/4.0:base
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/owned-manifests owned-manifests
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/install manifests
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/bin/machine-api-operator .
COPY --from=builder /go/src/github.com/openshift/machine-api-operator/bin/nodelink-controller .
Expand Down
19 changes: 11 additions & 8 deletions Gopkg.lock

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

15 changes: 11 additions & 4 deletions cmd/machine-api-operator/controller_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package main
import (
"time"

configinformersv1 "github.com/openshift/client-go/config/informers/externalversions"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/informers"
)
Expand All @@ -11,7 +14,8 @@ import (
type ControllerContext struct {
ClientBuilder *ClientBuilder

KubeNamespacedInformerFactory informers.SharedInformerFactory
KubeNamespacedInformerFactory informers.SharedInformerFactory
ConfigNamespacedInformerFactory configinformersv1.SharedInformerFactory

AvailableResources map[schema.GroupVersionResource]bool

Expand All @@ -25,12 +29,15 @@ type ControllerContext struct {
// CreateControllerContext creates the ControllerContext with the ClientBuilder.
func CreateControllerContext(cb *ClientBuilder, stop <-chan struct{}, targetNamespace string) *ControllerContext {
kubeClient := cb.KubeClientOrDie("kube-shared-informer")
openshiftClient := cb.OpenshiftClientOrDie("openshift-shared-informer")

kubeNamespacedSharedInformer := informers.NewFilteredSharedInformerFactory(kubeClient, resyncPeriod()(), targetNamespace, nil)
kubeNamespacedSharedInformer := informers.NewSharedInformerFactoryWithOptions(kubeClient, resyncPeriod()(), informers.WithNamespace(targetNamespace))
configNamespacesShareInformer := configinformersv1.NewSharedInformerFactoryWithOptions(openshiftClient, resyncPeriod()(), configinformersv1.WithNamespace(metav1.NamespaceNone))

return &ControllerContext{
ClientBuilder: cb,
KubeNamespacedInformerFactory: kubeNamespacedSharedInformer,
ClientBuilder: cb,
KubeNamespacedInformerFactory: kubeNamespacedSharedInformer,
ConfigNamespacedInformerFactory: configNamespacesShareInformer,
Stop: stop,
InformersStarted: make(chan struct{}),
ResyncPeriod: resyncPeriod(),
Expand Down
1 change: 1 addition & 0 deletions cmd/machine-api-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func startControllers(ctx *ControllerContext) error {

config,
ctx.KubeNamespacedInformerFactory.Apps().V1().Deployments(),
ctx.ConfigNamespacedInformerFactory.Config().V1().FeatureGates(),

ctx.ClientBuilder.KubeClientOrDie(componentName),
ctx.ClientBuilder.OpenshiftClientOrDie(componentName),
Expand Down
83 changes: 0 additions & 83 deletions owned-manifests/clusterapi-manager-controllers.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions pkg/operator/featuresgate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package operator

import (
"fmt"

osev1 "github.com/openshift/api/config/v1"
)

const (
// MachineAPIOperatorFeatureGate contains the name of the machine-api-operator FeatureGate object
MachineAPIOperatorFeatureGate = "machine-api-operator"

// FeatureGateMachineHealthCheck contains the name of the MachineHealthCheck feature gate
FeatureGateMachineHealthCheck = "machine-health-check"
)

// MachineAPIOperatorFeatureSets contains a map of machine-api-operator features names to Enabled/Disabled feature.
//
// NOTE: The caller needs to make sure to check for the existence of the value
// using golang's existence field. A possible scenario is an upgrade where new
// FeatureSets are added and a controller has not been upgraded with a newer
// version of this file. In this upgrade scenario the map could return nil.
//
// example:
// if featureSet, ok := MachineAPIOperatorFeatureSets["SomeNewFeature"]; ok { }
//
// If you put an item in either of these lists, put your area and name on it so we can find owners.
var MachineAPIOperatorFeatureSets = map[osev1.FeatureSet]*osev1.FeatureGateEnabledDisabled{
osev1.Default: {
Disabled: []string{
FeatureGateMachineHealthCheck, // machine-api-operator, alukiano
},
},
osev1.TechPreviewNoUpgrade: {
Enabled: []string{
FeatureGateMachineHealthCheck, // machine-api-operator, alukiano
},
},
}

func generateFeatureMap(featureSet osev1.FeatureSet) (map[string]bool, error) {
rv := map[string]bool{}
set, ok := MachineAPIOperatorFeatureSets[featureSet]
if !ok {
return nil, fmt.Errorf("enabled FeatureSet %v does not have a corresponding config", featureSet)
}
for _, featEnabled := range set.Enabled {
rv[featEnabled] = true
}
for _, featDisabled := range set.Disabled {
rv[featDisabled] = false
}
return rv, nil
}
15 changes: 12 additions & 3 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"time"

"github.com/golang/glog"
osconfigv1 "github.com/openshift/api/config/v1"
osclientset "github.com/openshift/client-go/config/clientset/versioned"
configinformersv1 "github.com/openshift/client-go/config/informers/externalversions/config/v1"
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"

osconfigv1 "github.com/openshift/api/config/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -29,8 +31,7 @@ const (
// a machineconfig pool is going to be requeued:
//
// 5ms, 10ms, 20ms, 40ms, 80ms, 160ms, 320ms, 640ms, 1.3s, 2.6s, 5.1s, 10.2s, 20.4s, 41s, 82s
maxRetries = 15
ownedManifestsDir = "owned-manifests"
maxRetries = 15
)

// Operator defines machine api operator.
Expand All @@ -49,6 +50,9 @@ type Operator struct {
deployLister appslisterv1.DeploymentLister
deployListerSynced cache.InformerSynced

featureGateLister configlistersv1.FeatureGateLister
featureGateCacheSync cache.InformerSynced

// queue only ever has one item, but it has nice error handling backoff/retry semantics
queue workqueue.RateLimitingInterface
operandVersions []osconfigv1.OperandVersion
Expand All @@ -62,6 +66,7 @@ func New(
config string,

deployInformer appsinformersv1.DeploymentInformer,
featureGateInformer configinformersv1.FeatureGateInformer,

kubeClient kubernetes.Interface,
osClient osclientset.Interface,
Expand Down Expand Up @@ -91,13 +96,17 @@ func New(
}

deployInformer.Informer().AddEventHandler(optr.eventHandler())
featureGateInformer.Informer().AddEventHandler(optr.eventHandler())

optr.config = config
optr.syncHandler = optr.sync

optr.deployLister = deployInformer.Lister()
optr.deployListerSynced = deployInformer.Informer().HasSynced

optr.featureGateLister = featureGateInformer.Lister()
optr.featureGateCacheSync = featureGateInformer.Informer().HasSynced

return optr
}

Expand Down
Loading