Skip to content

Commit

Permalink
Pr v1alpha2 ugprade cluster api dependency (#450)
Browse files Browse the repository at this point in the history
* upgrade cluster-api dependency

* adjust code to new clusterapi version
  • Loading branch information
sbueringer authored and k8s-ci-robot committed Aug 23, 2019
1 parent 3ac9dd8 commit c93fdde
Show file tree
Hide file tree
Showing 190 changed files with 4,205 additions and 4,815 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha2/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/pkg/errors"
"sigs.k8s.io/cluster-api/errors"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha2/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import (
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/provider"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/userdata"
"sigs.k8s.io/cluster-api/api/v1alpha2"
"sigs.k8s.io/cluster-api/pkg/util"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/patch"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -55,7 +56,7 @@ type OpenStackClusterReconciler struct {
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=openstackclusters/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=get;list;watch

func (r *OpenStackClusterReconciler) Reconcile(request ctrl.Request) (ctrl.Result, error) {
func (r *OpenStackClusterReconciler) Reconcile(request ctrl.Request) (_ ctrl.Result, reterr error) {
ctx := context.TODO()
logger := log.Log.WithName(clusterControllerName).
WithName(fmt.Sprintf("namespace=%s", request.Namespace)).
Expand Down Expand Up @@ -85,6 +86,18 @@ func (r *OpenStackClusterReconciler) Reconcile(request ctrl.Request) (ctrl.Resul

logger = logger.WithName(fmt.Sprintf("cluster=%s", cluster.Name))

patchHelper, err := patch.NewHelper(openStackCluster, r)
if err != nil {
return ctrl.Result{}, err
}
defer func() {
if err := patchHelper.Patch(ctx, openStackCluster); err != nil {
if reterr == nil {
reterr = errors.Wrapf(err, "error patching OpenStackCluster %s/%s", openStackCluster.Namespace, openStackCluster.Name)
}
}
}()

// Handle deleted clusters
if !openStackCluster.DeletionTimestamp.IsZero() {
return r.reconcileClusterDelete(logger, cluster, openStackCluster)
Expand All @@ -97,8 +110,6 @@ func (r *OpenStackClusterReconciler) Reconcile(request ctrl.Request) (ctrl.Resul
func (r *OpenStackClusterReconciler) reconcileCluster(logger logr.Logger, cluster *v1alpha2.Cluster, openStackCluster *infrav1.OpenStackCluster) (_ ctrl.Result, reterr error) {
klog.Infof("Reconciling Cluster %s/%s", cluster.Namespace, cluster.Name)

// openstackClusterPath is used for patch generation during storeCluster
openstackClusterPatch := client.MergeFrom(openStackCluster.DeepCopy())
clusterName := fmt.Sprintf("%s-%s", cluster.Namespace, cluster.Name)

osProviderClient, clientOpts, err := provider.NewClientFromCluster(r.Client, openStackCluster)
Expand All @@ -118,12 +129,6 @@ func (r *OpenStackClusterReconciler) reconcileCluster(logger logr.Logger, cluste
return reconcile.Result{}, err
}

defer func() {
if err := storeCluster(r.Client, openStackCluster, openstackClusterPatch); err != nil && reterr == nil {
reterr = err
}
}()

klog.Infof("Reconciling certificates for cluster %s", clusterName)
// Store cert material in spec.
if err := certificatesService.ReconcileCertificates(clusterName, openStackCluster); err != nil {
Expand Down Expand Up @@ -253,22 +258,6 @@ func (r *OpenStackClusterReconciler) reconcileClusterDelete(logger logr.Logger,
return reconcile.Result{}, nil
}

func storeCluster(ctrlClient client.Client, openStackCluster *infrav1.OpenStackCluster, openStackClusterPatch client.Patch) error {
ctx := context.TODO()

// Patch Cluster object.
if err := ctrlClient.Patch(ctx, openStackCluster, openStackClusterPatch); err != nil {
return errors.Wrapf(err, "error patching OpenStackCluster %s/%s", openStackCluster.Namespace, openStackCluster.Name)
}

// Patch Cluster status.
if err := ctrlClient.Status().Patch(ctx, openStackCluster, openStackClusterPatch); err != nil {
return errors.Wrapf(err, "error patching OpenStackCluster %s/%s status", openStackCluster.Namespace, openStackCluster.Name)
}

return nil
}

func (r *OpenStackClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&infrav1.OpenStackCluster{}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/provider"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/userdata"
"sigs.k8s.io/cluster-api/api/v1alpha2"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"strconv"
Expand All @@ -44,8 +45,8 @@ import (

apierrors "k8s.io/apimachinery/pkg/api/errors"
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha2"
capierrors "sigs.k8s.io/cluster-api/pkg/errors"
"sigs.k8s.io/cluster-api/pkg/util"
capierrors "sigs.k8s.io/cluster-api/errors"
"sigs.k8s.io/cluster-api/util"
)

const (
Expand All @@ -67,7 +68,7 @@ type OpenStackMachineReconciler struct {
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters;machines,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch

func (r *OpenStackMachineReconciler) Reconcile(request ctrl.Request) (ctrl.Result, error) {
func (r *OpenStackMachineReconciler) Reconcile(request ctrl.Request) (_ ctrl.Result, reterr error) {
ctx := context.TODO()
logger := log.Log.
WithName(machineControllerName).
Expand Down Expand Up @@ -119,6 +120,20 @@ func (r *OpenStackMachineReconciler) Reconcile(request ctrl.Request) (ctrl.Resul

logger = logger.WithName(fmt.Sprintf("openStackCluster=%s", openStackCluster.Name))

// Initialize the patch helper
patchHelper, err := patch.NewHelper(openStackMachine, r)
if err != nil {
return ctrl.Result{}, err
}
// Always attempt to Patch the Machine object and status after each reconciliation.
defer func() {
if err := patchHelper.Patch(ctx, openStackMachine); err != nil {
if reterr == nil {
reterr = err
}
}
}()

// Handle deleted clusters
if !openStackMachine.DeletionTimestamp.IsZero() {
return r.reconcileMachineDelete(logger, machine, openStackMachine, cluster, openStackCluster)
Expand Down Expand Up @@ -156,8 +171,6 @@ func (r *OpenStackMachineReconciler) reconcileMachine(logger logr.Logger, machin

clusterName := fmt.Sprintf("%s-%s", cluster.ObjectMeta.Namespace, cluster.Name)

openstackMachinePatch := client.MergeFrom(openStackMachine.DeepCopy())

osProviderClient, clientOpts, err := provider.NewClientFromMachine(r.Client, openStackMachine)
if err != nil {
return reconcile.Result{}, err
Expand All @@ -173,12 +186,6 @@ func (r *OpenStackMachineReconciler) reconcileMachine(logger logr.Logger, machin
return reconcile.Result{}, err
}

defer func() {
if err := storeMachine(r.Client, openStackMachine, openstackMachinePatch); err != nil && reterr == nil {
reterr = err
}
}()

instance, err := r.getOrCreate(computeService, machine, openStackMachine, cluster, openStackCluster)
if err != nil {
handleMachineError(openStackMachine, capierrors.UpdateMachineError, errors.Errorf("OpenStack instance cannot be created: %v", err))
Expand Down Expand Up @@ -334,22 +341,6 @@ func getTimeout(name string, timeout int) time.Duration {
return time.Duration(timeout)
}

func storeMachine(ctrlClient client.Client, openStackMachine *infrav1.OpenStackMachine, openStackMachinePatch client.Patch) error {
ctx := context.TODO()

// Patch Cluster object.
if err := ctrlClient.Patch(ctx, openStackMachine, openStackMachinePatch); err != nil {
return errors.Wrapf(err, "error patching OpenStackMachine %s/%s", openStackMachine.Namespace, openStackMachine.Name)
}

// Patch Cluster status.
if err := ctrlClient.Status().Patch(ctx, openStackMachine, openStackMachinePatch); err != nil {
return errors.Wrapf(err, "error patching OpenStackMachine %s/%s status", openStackMachine.Namespace, openStackMachine.Name)
}

return nil
}

func (r *OpenStackMachineReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&infrav1.OpenStackMachine{}).
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
k8s.io/klog v0.4.0
k8s.io/kubernetes v1.14.2
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5
sigs.k8s.io/cluster-api v0.1.9
sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5
sigs.k8s.io/controller-runtime v0.2.0-rc.0
sigs.k8s.io/controller-tools v0.2.0-rc.0
sigs.k8s.io/testing_frameworks v0.1.2-0.20190130140139-57f07443c2d4
Expand All @@ -38,5 +38,5 @@ replace (
gomodules.xyz/jsonpatch/v2 => gomodules.xyz/jsonpatch/v2 v2.0.0-20190626003512-87910169748d
k8s.io/api => k8s.io/api v0.0.0-20190704095032-f4ca3d3bdf1d
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190704094733-8f6ac2502e51
sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v0.0.0-20190813192342-65800b3b20e8
sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5
)
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,10 @@ k8s.io/kubernetes v1.14.2 h1:Gdq2hPpttbaJBoClIanCE6WSu4IZReA54yhkZtvPUOo=
k8s.io/kubernetes v1.14.2/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y=
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
sigs.k8s.io/cluster-api v0.0.0-20190813192342-65800b3b20e8 h1:eL1qZBKN+aQzl3Zhhnzl0JplS+EAtFuJoRalS1hQ9LI=
sigs.k8s.io/cluster-api v0.0.0-20190813192342-65800b3b20e8/go.mod h1:dRPbLOP8J7nde5WRB2opPY3JW+0OJ/v/wBuOPRNRieI=
sigs.k8s.io/controller-runtime v0.2.0-beta.5/go.mod h1:HweyYKQ8fBuzdu2bdaeBJvsFgAi/OqBBnrVGXcqKhME=
sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5 h1:UEoSiJ7vUhyob3knrvEHS1DDzbHY0p73kub/4BKhAHM=
sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5/go.mod h1:pmA/Jh0Hrs0dq4HkHWoInOSsmyPH8i65JNoqLXPZJNk=
sigs.k8s.io/controller-runtime v0.2.0-rc.0 h1:49JLOielmXfrd44Cmk2c0eeIkQ/Vq4AvfqsZqya16/E=
sigs.k8s.io/controller-runtime v0.2.0-rc.0/go.mod h1:HweyYKQ8fBuzdu2bdaeBJvsFgAi/OqBBnrVGXcqKhME=
sigs.k8s.io/controller-tools v0.2.0-beta.5/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y=
sigs.k8s.io/controller-tools v0.2.0-rc.0 h1:8FZR8qgxNPPBCb6Q/WwoRUfYqWvgn1Fz6m5uKcCbXfI=
sigs.k8s.io/controller-tools v0.2.0-rc.0/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y=
sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs=
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/openstack/services/compute/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"k8s.io/klog"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/networking"
"sigs.k8s.io/cluster-api/api/v1alpha2"
"sigs.k8s.io/cluster-api/pkg/controller/noderefutil"
"sigs.k8s.io/cluster-api/controllers/noderefutil"
"time"

"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
Expand All @@ -44,7 +44,7 @@ import (
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
"github.com/gophercloud/gophercloud/pagination"
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha2"
"sigs.k8s.io/cluster-api/pkg/util"
"sigs.k8s.io/cluster-api/util"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/openstack/services/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"k8s.io/klog"
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha2"
"sigs.k8s.io/cluster-api/api/v1alpha2"
"sigs.k8s.io/cluster-api/pkg/util"
"sigs.k8s.io/cluster-api/util"
"time"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/openstack/services/userdata/machinescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/certificates"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/compute"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/openstack/services/provider"
"sigs.k8s.io/cluster-api/pkg/util"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/controller-runtime/pkg/client"
"strings"
"text/template"
Expand All @@ -46,7 +46,7 @@ import (
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha2"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/bootstrap"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha2"
apierrors "sigs.k8s.io/cluster-api/pkg/errors"
apierrors "sigs.k8s.io/cluster-api/errors"
)

const (
Expand Down
6 changes: 2 additions & 4 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,9 @@ k8s.io/utils/exec
k8s.io/utils/integer
k8s.io/utils/pointer
k8s.io/utils/trace
# sigs.k8s.io/cluster-api v0.1.9 => sigs.k8s.io/cluster-api v0.0.0-20190813192342-65800b3b20e8
# sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5 => sigs.k8s.io/cluster-api v0.0.0-20190821154522-636a336cc6b5
sigs.k8s.io/cluster-api/api/v1alpha2
sigs.k8s.io/cluster-api/pkg/controller/noderefutil
sigs.k8s.io/cluster-api/pkg/errors
sigs.k8s.io/cluster-api/pkg/util
sigs.k8s.io/cluster-api/errors
# sigs.k8s.io/controller-runtime v0.2.0-rc.0
sigs.k8s.io/controller-runtime
sigs.k8s.io/controller-runtime/pkg/builder
Expand Down
13 changes: 2 additions & 11 deletions vendor/sigs.k8s.io/cluster-api/.github/PULL_REQUEST_TEMPLATE.md

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

4 changes: 3 additions & 1 deletion vendor/sigs.k8s.io/cluster-api/.gitignore

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

1 change: 1 addition & 0 deletions vendor/sigs.k8s.io/cluster-api/.golangci.yml

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

2 changes: 1 addition & 1 deletion vendor/sigs.k8s.io/cluster-api/BUILD.bazel

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

2 changes: 2 additions & 0 deletions vendor/sigs.k8s.io/cluster-api/CONTRIBUTING.md

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

11 changes: 2 additions & 9 deletions vendor/sigs.k8s.io/cluster-api/Dockerfile

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

Loading

0 comments on commit c93fdde

Please sign in to comment.