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
4 changes: 2 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func startControllers(ctx *controllerContext) error {
startOpts.nodeName,
componentNamespace, componentName,
rootOpts.releaseImage,
ctx.InformerFactory.Clusterversion().V1().CVOConfigs(),
ctx.InformerFactory.Config().V1().ClusterVersions(),
ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(),
ctx.APIExtInformerFactory.Apiextensions().V1beta1().CustomResourceDefinitions(),
ctx.KubeInformerFactory.Apps().V1().Deployments(),
Expand All @@ -244,7 +244,7 @@ func startControllers(ctx *controllerContext) error {
if startOpts.enableAutoUpdate {
go autoupdate.New(
componentNamespace, componentName,
ctx.InformerFactory.Clusterversion().V1().CVOConfigs(),
ctx.InformerFactory.Config().V1().ClusterVersions(),
ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(),
ctx.ClientBuilder.ClientOrDie(componentName),
ctx.ClientBuilder.KubeClientOrDie(componentName),
Expand Down
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ${PROJECT_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh \
all \
github.com/openshift/cluster-version-operator/pkg/generated \
github.com/openshift/cluster-version-operator/pkg/apis \
"clusterversion.openshift.io:v1 operatorstatus.openshift.io:v1" \
"config.openshift.io:v1 operatorstatus.openshift.io:v1" \
$@ \
10 changes: 5 additions & 5 deletions install/0000_00_cluster-version-operator_01_cvoconfig.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: cvoconfigs.clusterversion.openshift.io
name: clusterversions.config.openshift.io
spec:
# group name to use for REST API: /apis/<group>/<version>
group: clusterversion.openshift.io
group: config.openshift.io
# list of versions supported by this CustomResourceDefinition
versions:
- name: v1
Expand All @@ -20,8 +20,8 @@ spec:
status: {}
names:
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: cvoconfigs
plural: clusterversions
# singular name to be used as an alias on the CLI and for display
singular: cvoconfig
singular: clusterversion
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: CVOConfig
kind: ClusterVersion
28 changes: 14 additions & 14 deletions lib/resourceapply/cv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"

"github.com/openshift/cluster-version-operator/lib/resourcemerge"
cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1"
cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/config.openshift.io/v1"
osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1"
cvclientv1 "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1"
cvclientv1 "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/typed/config.openshift.io/v1"
osclientv1 "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1"
cvlistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/clusterversion.openshift.io/v1"
cvlistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/config.openshift.io/v1"
oslistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/operatorstatus.openshift.io/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -63,45 +63,45 @@ func ApplyOperatorStatusFromCache(lister oslistersv1.ClusterOperatorLister, clie
return actual, true, err
}

func ApplyCVOConfig(client cvclientv1.CVOConfigsGetter, required *cvv1.CVOConfig) (*cvv1.CVOConfig, bool, error) {
existing, err := client.CVOConfigs(required.Namespace).Get(required.Name, metav1.GetOptions{})
func ApplyClusterVersion(client cvclientv1.ClusterVersionsGetter, required *cvv1.ClusterVersion) (*cvv1.ClusterVersion, bool, error) {
existing, err := client.ClusterVersions(required.Namespace).Get(required.Name, metav1.GetOptions{})
if errors.IsNotFound(err) {
actual, err := client.CVOConfigs(required.Namespace).Create(required)
actual, err := client.ClusterVersions(required.Namespace).Create(required)
return actual, true, err
}
if err != nil {
return nil, false, err
}

modified := pointer.BoolPtr(false)
resourcemerge.EnsureCVOConfig(modified, existing, *required)
resourcemerge.EnsureClusterVersion(modified, existing, *required)
if !*modified {
return existing, false, nil
}

actual, err := client.CVOConfigs(required.Namespace).Update(existing)
actual, err := client.ClusterVersions(required.Namespace).Update(existing)
return actual, true, err
}

func ApplyCVOConfigFromCache(lister cvlistersv1.CVOConfigLister, client cvclientv1.CVOConfigsGetter, required *cvv1.CVOConfig) (*cvv1.CVOConfig, bool, error) {
obj, err := lister.CVOConfigs(required.Namespace).Get(required.Name)
func ApplyClusterVersionFromCache(lister cvlistersv1.ClusterVersionLister, client cvclientv1.ClusterVersionsGetter, required *cvv1.ClusterVersion) (*cvv1.ClusterVersion, bool, error) {
obj, err := lister.ClusterVersions(required.Namespace).Get(required.Name)
if errors.IsNotFound(err) {
actual, err := client.CVOConfigs(required.Namespace).Create(required)
actual, err := client.ClusterVersions(required.Namespace).Create(required)
return actual, true, err
}
if err != nil {
return nil, false, err
}

// Don't want to mutate cache.
existing := new(cvv1.CVOConfig)
existing := new(cvv1.ClusterVersion)
obj.DeepCopyInto(existing)
modified := pointer.BoolPtr(false)
resourcemerge.EnsureCVOConfig(modified, existing, *required)
resourcemerge.EnsureClusterVersion(modified, existing, *required)
if !*modified {
return existing, false, nil
}

actual, err := client.CVOConfigs(required.Namespace).Update(existing)
actual, err := client.ClusterVersions(required.Namespace).Update(existing)
return actual, true, err
}
4 changes: 2 additions & 2 deletions lib/resourcemerge/cv.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package resourcemerge

import (
cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1"
cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/config.openshift.io/v1"
)

func EnsureCVOConfig(modified *bool, existing *cvv1.CVOConfig, required cvv1.CVOConfig) {
func EnsureClusterVersion(modified *bool, existing *cvv1.ClusterVersion, required cvv1.ClusterVersion) {
EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta)
if existing.Upstream != required.Upstream {
*modified = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/apis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apis

// ClusterVersionGroupName defines the API group for clusterversion.
const ClusterVersionGroupName = "clusterversion.openshift.io"
const ClusterVersionGroupName = "config.openshift.io"

// OperatorStatusGroupName defines the API group for operatorstatus.
const OperatorStatusGroupName = "operatorstatus.openshift.io"
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

// DeepCopyObject copies the CVOConfig into an Object. This doesn't actually
// DeepCopyObject copies the ClusterVersion into an Object. This doesn't actually
// require a deep copy, but the code generator (and Go itself) isn't advanced
// enough to determine that.
func (c *CVOConfig) DeepCopyObject() runtime.Object {
func (c *ClusterVersion) DeepCopyObject() runtime.Object {
out := *c
c.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
return &out
}

// DeepCopyInto copies the CVOConfig into another CVOConfig. This doesn't
// DeepCopyInto copies the ClusterVersion into another ClusterVersion. This doesn't
// actually require a deep copy, but the code generator (and Go itself) isn't
// advanced enough to determine that.
func (c *CVOConfig) DeepCopyInto(out *CVOConfig) {
func (c *ClusterVersion) DeepCopyInto(out *ClusterVersion) {
*out = *c
c.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
}

func (c CVOConfig) String() string {
func (c ClusterVersion) String() string {
return fmt.Sprintf("{ Upstream: %s Channel: %s ClusterID: %s }", c.Upstream, c.Channel, c.ClusterID)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func init() {
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CVOConfig{},
&ClusterVersion{},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-existing, but where is the list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

&ClusterVersionList{},
&CVOStatus{},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stands out now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the spec/status split discussion can happen as a second step here. I will create a PR that has those additional commits so we can look at it.

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CVOConfigList is a list of CVOConfig resources.
// ClusterVersionList is a list of ClusterVersion resources.
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type CVOConfigList struct {
type ClusterVersionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []CVOConfig `json:"items"`
Items []ClusterVersion `json:"items"`
}

// CVOConfig is the configuration for the ClusterVersionOperator. This is where
// ClusterVersion is the configuration for the ClusterVersionOperator. This is where
// parameters related to automatic updates can be set.
// +genclient
type CVOConfig struct {
type ClusterVersion struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Expand Down

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

24 changes: 12 additions & 12 deletions pkg/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"github.com/golang/glog"
"github.com/openshift/cluster-version-operator/lib/resourceapply"
"github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1"
"github.com/openshift/cluster-version-operator/pkg/apis/config.openshift.io/v1"
clientset "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned"
"github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/scheme"
cvinformersv1 "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1"
cvinformersv1 "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/config.openshift.io/v1"
osinformersv1 "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1"
cvlistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/clusterversion.openshift.io/v1"
cvlistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/config.openshift.io/v1"
oslistersv1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/operatorstatus.openshift.io/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -38,15 +38,15 @@ const (

// Controller defines autoupdate controller.
type Controller struct {
// namespace and name are used to find the CVOConfig, ClusterOperator.
// namespace and name are used to find the ClusterVersion, ClusterOperator.
namespace, name string

client clientset.Interface
eventRecorder record.EventRecorder

syncHandler func(key string) error

cvoConfigLister cvlistersv1.CVOConfigLister
cvoConfigLister cvlistersv1.ClusterVersionLister
clusterOperatorLister oslistersv1.ClusterOperatorLister

cvoConfigListerSynced cache.InformerSynced
Expand All @@ -59,7 +59,7 @@ type Controller struct {
// New returns a new autoupdate controller.
func New(
namespace, name string,
cvoConfigInformer cvinformersv1.CVOConfigInformer,
cvoConfigInformer cvinformersv1.ClusterVersionInformer,
clusterOperatorInformer osinformersv1.ClusterOperatorInformer,
client clientset.Interface,
kubeClient kubernetes.Interface,
Expand Down Expand Up @@ -177,9 +177,9 @@ func (ctrl *Controller) sync(key string) error {
return err
}

cvoconfig, err := ctrl.cvoConfigLister.CVOConfigs(namespace).Get(name)
clusterversion, err := ctrl.cvoConfigLister.ClusterVersions(namespace).Get(name)
if errors.IsNotFound(err) {
glog.V(2).Infof("CVOConfig %v has been deleted", key)
glog.V(2).Infof("ClusterVersion %v has been deleted", key)
return nil
}
if err != nil {
Expand All @@ -189,8 +189,8 @@ func (ctrl *Controller) sync(key string) error {
// Deep-copy otherwise we are mutating our cache.
// TODO: Deep-copy only when needed.
ops := operatorstatus.DeepCopy()
config := new(v1.CVOConfig)
cvoconfig.DeepCopyInto(config)
config := new(v1.ClusterVersion)
clusterversion.DeepCopyInto(config)

obji, _, err := scheme.Codecs.UniversalDecoder().Decode(ops.Status.Extension.Raw, nil, &v1.CVOStatus{})
if err != nil {
Expand All @@ -207,9 +207,9 @@ func (ctrl *Controller) sync(key string) error {
up := nextUpdate(cvoststatus.AvailableUpdates)
config.DesiredUpdate = up

_, updated, err := resourceapply.ApplyCVOConfigFromCache(ctrl.cvoConfigLister, ctrl.client.ClusterversionV1(), config)
_, updated, err := resourceapply.ApplyClusterVersionFromCache(ctrl.cvoConfigLister, ctrl.client.ConfigV1(), config)
if updated {
glog.Info("Auto Update set to %s", up)
glog.Infof("Auto Update set to %s", up)
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoupdate/autoupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1"
"github.com/openshift/cluster-version-operator/pkg/apis/config.openshift.io/v1"
)

func TestNextUpdate(t *testing.T) {
Expand Down
Loading