-
Notifications
You must be signed in to change notification settings - Fork 139
Wire cloud-provider to kube-controller-manager #65
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
Wire cloud-provider to kube-controller-manager #65
Conversation
|
/hold |
| "k8s.io/client-go/rest" | ||
| ) | ||
|
|
||
| func TestObserveClusterConfig(t *testing.T) { |
There was a problem hiding this comment.
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: {} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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{}{} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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{}) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (I think)
pkg/operator/observe_config.go
Outdated
| // extendedArguments: | ||
| // cloud-provider: | ||
| // - "name" | ||
| if len(cloudProvider) > 0 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
|
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. |
|
/hold cancel |
|
Spoke with @deads2k, decided to use the current cluster config available to use to get started. |
|
/approve |
b3886a0 to
b96bfb0
Compare
|
Squashed |
| return observedConfig, nil | ||
| } | ||
| if err != nil { | ||
| return observedConfig, err |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
|
/lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
e2e failure is reminiscent of openshift/installer#606 |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest |
|
This is what I get for rebasing. 😭 /retest |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest |
|
From my testing I'm pretty sure this also fixed openshift/installer#530. |
Fixes openshift/installer#577.
Related to openshift/installer#530.