Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a deep copy of cluster prior to calling actuator #426

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

detiber
Copy link
Member

@detiber detiber commented Jul 12, 2018

What this PR does / why we need it:

Currently the Machine Controller and Custer Controller differ in the handling of the informer provided object that they pass into the Actuators. This PR aligns the Cluster Controller handling of the informer provided object to match that of the Machine Controller.

Changes:

  • Provide the cluster actuator methods with a deep copy of the informer provided cluster object rather than the informer provided object directly.
    • This reduces error prone handling of the informer provided object in the cluster actuator
    • This also matches the current behavior of the machine controller

Which issue(s) this PR fixes:
Fixes #420

Release note:

- The Cluster Actuator is now passed a deep copy of the informer-provided cluster object instead of the informer-provided cluster object directly.

@kubernetes/kube-deploy-reviewers

@k8s-ci-robot k8s-ci-robot requested review from karan and rsdcastro July 12, 2018 14:31
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 12, 2018
@detiber
Copy link
Member Author

detiber commented Jul 12, 2018

/assign @mkjelland

@detiber
Copy link
Member Author

detiber commented Jul 12, 2018

@mkjelland PTAL, this PR only modifies the handling of the informer-provided object provided to the Cluster Actuator.

name := cluster.Name
// Deep-copy otherwise we are mutating our cache.
clusterCopy := cluster.DeepCopy()
name := clusterCopy.Name
glog.Infof("Running reconcile Cluster for %s\n", name)

if !cluster.ObjectMeta.DeletionTimestamp.IsZero() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the machine controller, it seems like this line and line 81 should also use clusterCopy instead of cluster. Is there a reason to use the original object in these cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

There was not, fixed in latest. Thanks!

@detiber
Copy link
Member Author

detiber commented Jul 12, 2018

/test pull-cluster-api-test

@mkjelland
Copy link
Contributor

lgtm

@karan @rsdcastro: Can one of you add the lgtm label?

@roberthbailey
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 17, 2018
@roberthbailey
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: detiber, roberthbailey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2018
@k8s-ci-robot k8s-ci-robot merged commit 6fd6b3d into kubernetes-sigs:master Jul 17, 2018
@detiber detiber deleted the deepCopyMachine branch April 2, 2019 17:44
jayunit100 pushed a commit to jayunit100/cluster-api that referenced this pull request Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cluster Actuator should be passed a deep copy of the cluster object instead of the informer provided object
4 participants