Skip to content

Conversation

@ironcladlou
Copy link
Contributor

@ironcladlou ironcladlou commented Oct 30, 2018

@ironcladlou
Copy link
Contributor Author

/hold

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2018
"k8s.io/client-go/rest"
)

func TestObserveClusterConfig(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test needs refactored to use tables, not going to bother until we're consuming data from the right place

// data:
// install-config:
// platform:
// aws: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't the right place to get cloud provider info from; I'm just using it for testing.

}

installConfigYaml, ok := clusterConfig.Data["install-config"]
if !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

check for the length here, in case of an empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it matters given we check for deserialization errors

Copy link
Contributor

@deads2k deads2k Nov 1, 2018

Choose a reason for hiding this comment

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

Not sure it matters given we check for deserialization errors

In preference to an ok. That's fairly standard in the overall kube codebase. Using len is more standard

// aws: {}
cloudProvider := ""
platform, ok := installConfig["platform"].(map[string]interface{})
if !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

check for empty values as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it matter given we check for unmarshaling errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, previous comment applies to another line... what do you mean re: empty value here? if the type conversion works I have a map to work with

if !ok {
return observedConfig, nil
}
installConfig := map[string]interface{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

would like to see if we can vendor installer's type rather than this map[string]interface{}, install-config has Name func on platform see here that can be used to make decisions.

Copy link
Contributor

Choose a reason for hiding this comment

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

would like to see if we can vendor installer's type rather than this map[string]interface{}, install-config has Name func on platform see here that can be used to make decisions.

Once the type is promoted to openshift/api we can do that, but I don't want to start having different operators depend on each other for types. If you do that, we'll end up wedged as we try to rebase to various levels of kube.

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, this is a pervasive issue that cuts across all my team's operators (and now this one). Not going to solve it with this PR.

// cluster-config-v1 in order to configure kube-controller-manager's cloud
// provider.
func observeClusterConfig(kubeClient kubernetes.Interface, clientConfig *rest.Config, observedConfig map[string]interface{}) (map[string]interface{}, error) {
clusterConfig, err := kubeClient.CoreV1().ConfigMaps("kube-system").Get("cluster-config-v1", metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the namespace scoped informer being plumbed to the control loop to watch for events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (I think)

// extendedArguments:
// cloud-provider:
// - "name"
if len(cloudProvider) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we returned above, is this if still needed or can we do it unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 31, 2018
@ironcladlou
Copy link
Contributor Author

Just to be totally clear, the current PR is a WIP; I'm inferring cloud provider config from some existing cluster config that happens to be useful but which isn't really designed to be cloud provider config. Before this is mergeable we might need an installer PR to introduce cloud provider stuff to the cluster config and then refactor this code to use the new purposefully introduced cloud provider config.

@ironcladlou
Copy link
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 2, 2018
@ironcladlou
Copy link
Contributor Author

Spoke with @deads2k, decided to use the current cluster config available to use to get started.

@deads2k
Copy link
Contributor

deads2k commented Nov 5, 2018

/approve
/assign @juanvallejo

@ironcladlou ironcladlou force-pushed the cloud-provider-wiring branch from b3886a0 to b96bfb0 Compare November 5, 2018 14:59
@ironcladlou
Copy link
Contributor Author

Squashed

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2018
return observedConfig, nil
}
if err != nil {
return observedConfig, err
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in the future, might be good to just explicitly return nil here for observedConfig

err = yaml.Unmarshal([]byte(installConfigYaml), &installConfig)
if err != nil {
glog.Warningf("Unable to parse install-config: %s", err)
return observedConfig, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason why we would not return the error here?

@juanvallejo
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, ironcladlou, juanvallejo

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

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

e2e failure is reminiscent of openshift/installer#606

@openshift-bot
Copy link
Contributor

/retest

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

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

This is what I get for rebasing. 😭

/retest

@openshift-bot
Copy link
Contributor

/retest

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

@ironcladlou
Copy link
Contributor Author

/retest

@ironcladlou
Copy link
Contributor Author

From my testing I'm pretty sure this also fixed openshift/installer#530.

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants