Skip to content

Provider image substitution#29

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Danil-Grigorev:image-substitution
May 3, 2021
Merged

Provider image substitution#29
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Danil-Grigorev:image-substitution

Conversation

@Danil-Grigorev
Copy link
Copy Markdown

@Danil-Grigorev Danil-Grigorev commented Mar 25, 2021

This PR allows operator to dynamically configure image in provisioned resources such as CCM Deployment.

This is done based on assumption that every CCM controller will be in a named container containing controller substring in it's name. All those containers images will be managed by operator, others will remain unchanged from initial manifest.

Operator is now populating Namespace for each resource it provisions. Cluster-scoped resources are also getting this namespace value, which is ok as it is not accounted and is not stored by API server on apply. This allows two operators to manage equivalent set of resources in different namespaces without clashes.

  • Testing

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 25, 2021
Comment thread controllers/clusteroperator_controller.go Outdated
Comment thread controllers/clusteroperator_controller.go Outdated
Comment thread controllers/clusteroperator_controller.go Outdated
Comment thread controllers/config.go Outdated
Comment thread controllers/config.go Outdated
Comment thread controllers/substitution.go Outdated
var (
// commonControllerNamingSubstringPattern contains a substring which all CCM controller container names should have
// to be substituted with image from config
commonControllerNamingSubstringPattern = "controller"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the pattern here is good, might be better to use something explicit though, eg, if we have a list of predefined allowed values cloud-controller-manager, node-controller-manager etc that the manifests must obide by? WDYT?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We need some sort of CI task which will check that only those names are on containers and other subresources all the time.

Comment thread controllers/substitution.go Outdated
for i, objectTemplate := range templates {
templateCopy := objectTemplate

// Set namespaces for all object. Namespace on cluster-wide objects is stripped by API server and is not applied
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good comment

@Danil-Grigorev Danil-Grigorev changed the title [WIP] Provider image substitution Provider image substitution Apr 20, 2021
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 20, 2021
@Danil-Grigorev
Copy link
Copy Markdown
Author

/test e2e-openstack

Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

I think we need to clean this up a bit before we merge. I'm concerned about the side effects of some of the functions and also premature optimisations we are making. Let's keep the code clean now and worry about future changes later when we get to that point

Comment thread controllers/clusteroperator_controller.go Outdated
Comment thread controllers/config.go Outdated
Comment thread controllers/substitution.go
@Danil-Grigorev Danil-Grigorev force-pushed the image-substitution branch 3 times, most recently from 8c032ed to 96f8c01 Compare April 21, 2021 18:23
Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

In general, would be good to see some more unit testing for the methods we are adding here. There are lots of small parts (which is good!) but at the moment their functionality is only tested as a whole. If we introduce more scoped down unit testing this will help us to prove that individual functions are doing what we are intending them to do and in the long run will help identifying bugs (add test cases to specific functions and check the outputs)

Comment thread controllers/clusteroperator_controller.go Outdated
@Danil-Grigorev Danil-Grigorev force-pushed the image-substitution branch 2 times, most recently from 4f18105 to c7c1fcb Compare April 23, 2021 13:46
@Danil-Grigorev
Copy link
Copy Markdown
Author

/retest

2 similar comments
@Danil-Grigorev
Copy link
Copy Markdown
Author

/retest

@Danil-Grigorev
Copy link
Copy Markdown
Author

/retest

@Danil-Grigorev
Copy link
Copy Markdown
Author

Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Couple of nits but otherwise LGTM

Comment thread controllers/config.go Outdated
Comment thread controllers/config_test.go Outdated
Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/approve

Thanks Danil, looks great!

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2021
@Danil-Grigorev
Copy link
Copy Markdown
Author

/retetst

Copy link
Copy Markdown
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

this mostly makes sense to me, i have a couple questions though

Comment thread controllers/config.go
type imagesReference struct {
CloudControllerManagerAWS string `json:"cloudControllerManagerAWS"`
CloudControllerManagerOpenStack string `json:"cloudControllerManagerOpenStack"`
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm just curious, will a cluster ever use multiple images from this reference?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, this is possible, there is definitely going to be a kube-rbac-proxy image here once we will start investigating metrics support.

Comment thread controllers/config.go
}

func getImagesFromJSONFile(filePath string) (imagesReference, error) {
data, err := ioutil.ReadFile(filepath.Clean(filePath))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these file paths loaded as volume mounts in the container?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, they are loaded from a mounted config map introduced in #31

Comment thread controllers/substitution.go Outdated
Comment thread controllers/substitution.go Outdated
Comment thread controllers/clusteroperator_controller_test.go
Copy link
Copy Markdown
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

looking mostly good Danil, i have one small suggestion and a question about the tests

@Danil-Grigorev Danil-Grigorev requested a review from elmiko May 3, 2021 08:12
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 3, 2021

@Danil-Grigorev: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-ccm e2a53a0 link /test e2e-aws-ccm

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Copy Markdown
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

thanks Danil!
/lgtm

@openshift-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elmiko, JoelSpeed

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

The pull request process is described here

Details 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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 3, 2021
@openshift-bot
Copy link
Copy Markdown

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Copy Markdown

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit e4fbd6c into openshift:master May 3, 2021
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants