Skip to content

Commit

Permalink
Merge pull request #305 from cgwalters/cvo-integration-prep-0
Browse files Browse the repository at this point in the history
Add osimageurl to release payload and controllerconfig
  • Loading branch information
openshift-merge-robot authored Jan 16, 2019
2 parents 72c13f9 + b5ec446 commit 5d43d89
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/machine-config-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func startControllers(ctx *common.ControllerContext) error {
ctx.KubeNamespacedInformerFactory.Apps().V1().DaemonSets(),
ctx.KubeNamespacedInformerFactory.Rbac().V1().ClusterRoles(),
ctx.KubeNamespacedInformerFactory.Rbac().V1().ClusterRoleBindings(),
ctx.KubeNamespacedInformerFactory.Core().V1().ConfigMaps(),
ctx.ClientBuilder.MachineConfigClientOrDie(componentName),
ctx.ClientBuilder.KubeClientOrDie(componentName),
ctx.ClientBuilder.APIExtClientOrDie(componentName),
Expand Down
9 changes: 9 additions & 0 deletions install/0000_50_machine-config-operator_05_osimageurl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: machine-config-osimageurl
namespace: openshift-machine-config-operator
data:
# The OS payload, managed by the daemon + pivot + rpm-ostree
# https://github.com/openshift/machine-config-operator/issues/183
osImageURL: "registry.svc.ci.openshift.org/rhcos/maipo@sha256:61dc83d62cfb5054c4c5532bd2478742a0711075ef5151572e63f94babeacc1a"
8 changes: 8 additions & 0 deletions install/image-references
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ kind: ImageStream
apiVersion: image.openshift.io/v1
spec:
tags:
# These are the 4 components of the MCO
- name: machine-config-operator
from:
kind: DockerImage
Expand All @@ -18,3 +19,10 @@ spec:
from:
kind: DockerImage
name: docker.io/openshift/origin-machine-config-daemon:v4.0.0
# This one is special, it's the OS payload
# https://github.com/openshift/machine-config-operator/issues/183
# See the machine-config-osimageurl configmap.
- name: machine-os-content
from:
kind: DockerImage
name: registry.svc.ci.openshift.org/rhcos/maipo@sha256:61dc83d62cfb5054c4c5532bd2478742a0711075ef5151572e63f94babeacc1a
1 change: 1 addition & 0 deletions lib/resourcemerge/machineconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func ensureControllerConfigSpec(modified *bool, existing *mcfgv1.ControllerConfi
setStringIfSet(modified, &existing.Platform, required.Platform)
setStringIfSet(modified, &existing.BaseDomain, required.BaseDomain)
setStringIfSet(modified, &existing.SSHKey, required.SSHKey)
setStringIfSet(modified, &existing.OSImageURL, required.OSImageURL)

setBytesIfSet(modified, &existing.EtcdCAData, required.EtcdCAData)
setBytesIfSet(modified, &existing.RootCAData, required.RootCAData)
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/machineconfiguration.openshift.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ type ControllerConfigSpec struct {

// Public SSH
SSHKey string `json:"sshKey"`

// Sourced from configmap/machine-config-osimageurl
OSImageURL string `json:"osImageURL`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RenderBootstrap(
return fmt.Errorf("error discovering MCOConfig from %q: %v", clusterConfigConfigMapFile, err)
}

config := getRenderConfig(mcoconfig, filesData[etcdCAFile], filesData[rootCAFile], nil, imgs)
config := getRenderConfig(mcoconfig, filesData[etcdCAFile], filesData[rootCAFile], nil, imgs, "")

manifests := []struct {
name string
Expand Down
30 changes: 28 additions & 2 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/client-go/kubernetes"
coreclientsetv1 "k8s.io/client-go/kubernetes/typed/core/v1"
appslisterv1 "k8s.io/client-go/listers/apps/v1"
corelisterv1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
Expand All @@ -45,6 +46,9 @@ const (
//
// 5ms, 10ms, 20ms, 40ms, 80ms, 160ms, 320ms, 640ms, 1.3s, 2.6s, 5.1s, 10.2s, 20.4s, 41s, 82s
maxRetries = 15

// osImageConfigMapName is the name of our configmap for the osImageURL
osImageConfigMapName = "machine-config-osimageurl"
)

// Operator defines machince config operator.
Expand All @@ -67,11 +71,13 @@ type Operator struct {
mcLister mcfglistersv1.MachineConfigLister
deployLister appslisterv1.DeploymentLister
daemonsetLister appslisterv1.DaemonSetLister
cmLister corelisterv1.ConfigMapLister

crdListerSynced cache.InformerSynced
mcoconfigListerSynced cache.InformerSynced
deployListerSynced cache.InformerSynced
daemonsetListerSynced cache.InformerSynced
cmListerSynced cache.InformerSynced

// queue only ever has one item, but it has nice error handling backoff/retry semantics
queue workqueue.RateLimitingInterface
Expand All @@ -91,6 +97,7 @@ func New(
daemonsetInformer appsinformersv1.DaemonSetInformer,
clusterRoleInformer rbacinformersv1.ClusterRoleInformer,
clusterRoleBindingInformer rbacinformersv1.ClusterRoleBindingInformer,
cmInformer coreinformersv1.ConfigMapInformer,
client mcfgclientset.Interface,
kubeClient kubernetes.Interface,
apiExtClient apiextclientset.Interface,
Expand Down Expand Up @@ -120,6 +127,7 @@ func New(
daemonsetInformer.Informer().AddEventHandler(optr.eventHandler())
clusterRoleInformer.Informer().AddEventHandler(optr.eventHandler())
clusterRoleBindingInformer.Informer().AddEventHandler(optr.eventHandler())
cmInformer.Informer().AddEventHandler(optr.eventHandler())

optr.syncHandler = optr.sync

Expand All @@ -133,6 +141,8 @@ func New(
optr.deployListerSynced = deployInformer.Informer().HasSynced
optr.daemonsetLister = daemonsetInformer.Lister()
optr.daemonsetListerSynced = daemonsetInformer.Informer().HasSynced
optr.cmLister = cmInformer.Lister()
optr.cmListerSynced = cmInformer.Informer().HasSynced

return optr
}
Expand All @@ -149,6 +159,7 @@ func (optr *Operator) Run(workers int, stopCh <-chan struct{}) {
optr.crdListerSynced,
optr.mcoconfigListerSynced,
optr.deployListerSynced,
optr.cmListerSynced,
optr.daemonsetListerSynced) {
glog.Error("failed to sync caches")
return
Expand Down Expand Up @@ -255,10 +266,24 @@ func (optr *Operator) sync(key string) error {
return err
}

rc := getRenderConfig(mcoconfig, etcdCA, rootCA, &v1.ObjectReference{Namespace: "kube-system", Name: "coreos-pull-secret"}, imgs)
osimageurl, err := optr.getOsImageURL(namespace)
glog.Infof("using osimageurl: %s", osimageurl)
if err != nil {
return err
}

rc := getRenderConfig(mcoconfig, etcdCA, rootCA, &v1.ObjectReference{Namespace: "kube-system", Name: "coreos-pull-secret"}, imgs, osimageurl)
return optr.syncAll(rc)
}

func (optr *Operator) getOsImageURL(namespace string) (string, error) {
cm, err := optr.kubeClient.CoreV1().ConfigMaps(namespace).Get(osImageConfigMapName, metav1.GetOptions{})
if err != nil {
return "", err
}
return cm.Data["osImageURL"], nil
}

func (optr *Operator) getCAsFromConfigMap(namespace, name, key string) ([]byte, error) {
cm, err := optr.kubeClient.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -307,7 +332,7 @@ func icFromClusterConfig(cm *v1.ConfigMap) (installertypes.InstallConfig, error)
return ic, nil
}

func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1.ObjectReference, imgs Images) renderConfig {
func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1.ObjectReference, imgs Images, osimageurl string) renderConfig {
controllerconfig := mcfgv1.ControllerConfigSpec{
ClusterDNSIP: mc.Spec.ClusterDNSIP,
CloudProviderConfig: mc.Spec.CloudProviderConfig,
Expand All @@ -318,6 +343,7 @@ func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1
RootCAData: rootCAData,
PullSecret: ps,
SSHKey: mc.Spec.SSHKey,
OSImageURL: osimageurl,
}
return renderConfig{
TargetNamespace: mc.GetNamespace(),
Expand Down

0 comments on commit 5d43d89

Please sign in to comment.