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

Allow to read openstack cloud provider config from a secret #89885

Closed

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Apr 6, 2020

This patch introduces new changes to allow reading openstack cloud provider config from a secret.

This change includes:

  • Ability to read metadata values for kubelet. Since the service does not have access to the secret to read the configuration, but it needs data to download (e.g. hostname or flavor), we are trying to get it from the metadata server.

  • Deprecation of kubeConfig parameter. Now we read the file that was provided with --kubeconfig option.

/kind feature

Allow to read openstack cloud provider config from a secret

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/cloudprovider sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 6, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Fedosin
To complete the pull request process, please assign dims
You can assign the PR to them by writing /assign @dims in a comment when ready.

The full list of commands accepted by this bot can be found 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 kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 6, 2020
@Fedosin Fedosin force-pushed the openstack_cloud_provider_secret branch from c47a87a to e0f3ae2 Compare April 6, 2020 11:15
}

secret, err := k8sClient.CoreV1().Secrets(secretNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
secretName := os.secretName
secretNamespace := os.secretNamespace
Copy link
Contributor

Choose a reason for hiding this comment

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

why copy values? just access directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return err
}

cfg := &Config{}
Copy link
Contributor

Choose a reason for hiding this comment

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

why have this here outside of the if clause if it is only used inside?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if err != nil {
return nil, false
}

Copy link
Contributor

Choose a reason for hiding this comment

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

why does it matter to initialize here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I did it for consistency, but there is no need to initialize here.

@@ -44,10 +44,36 @@ const (
instanceShutoff = "SHUTOFF"
)

func (os *OpenStack) getCompute() *gophercloud.ServiceClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nowhere, removed

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
err = fmt.Errorf("unexpected status code when reading instance type from %s: %s", instanceTypeURL, resp.Status)
Copy link
Contributor

@sttts sttts Apr 6, 2020

Choose a reason for hiding this comment

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

why assign to err and not just return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
err = fmt.Errorf("unexpected status code when reading instance address from %s: %s", url, resp.Status)
Copy link
Contributor

@sttts sttts Apr 6, 2020

Choose a reason for hiding this comment

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

why assign to err and not just return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

err = checkOpenStackOpts(&os)
err := checkOpenStackOpts(&os)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if err := ...; err != nil {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Fedosin Fedosin force-pushed the openstack_cloud_provider_secret branch from e0f3ae2 to 33714e4 Compare April 6, 2020 12:28
@Fedosin
Copy link
Contributor Author

Fedosin commented Apr 6, 2020

/test pull-kubernetes-node-e2e-containerd

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Apr 6, 2020

@Fedosin: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-node-e2e-containerd 33714e47e79df7bb5e4973aa043cbfe77a492f97 link /test pull-kubernetes-node-e2e-containerd

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

mdbooth added a commit to shiftstack/kubernetes that referenced this pull request Jul 20, 2022
... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/kubernetes that referenced this pull request Jul 20, 2022
... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/kubernetes that referenced this pull request Aug 10, 2022
... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
soltysh pushed a commit to soltysh/kubernetes that referenced this pull request Aug 19, 2022
… secret

This patch brings back the downstream changes that were introduced
to allow reading openstack cloud provider config from a secret.
They are available in release-4.4, but were reverted in master with
openshift/origin#24719

This change includes:

- Ability to read metadata values for kubelet. Since the service
does not have access to the secret to read the configuration, but
it needs data to download (e.g. hostname or flavor), we are trying
to get it from the metadata server.

- Deprecation of kubeConfig parameter. Now we read the file that
was provided with --kubeconfig option.

Origin-commit: f95edc26155a29769b3c5b80c03755a01a87b5fc

UPSTREAM: 89885: legacy-cloud-provider/openstack: include / prefix in instance ID output

When we want to read an instance ID from the metadata service, cloud provider
doesn't include "/" prefix, which is required for successful parsing of
provider the ID later.
This commit adds the missing "/" prefix to the output.

UPSTREAM: 89885: SQUASH: Fix Cinder provisioning crashing on nil cloud provider

OpenStack cloud provider must not use nil when provisioning a Cinder
volume.

UPSTREAM: 89885: SQUASH: Report OpenStack cloud initialization errors

openshift-rebase(v1.24):source=dbe70e455ee

UPSTREAM: <carry>: Set informer for openstack

Set informer for the openstack cloud provider to ensure it is properly
initialized when reading config from a secret.

Upstream 89885 was closed in favor of 96750.

Co-authored-by: Hemant Kumar <hekumar@redhat.com>

openshift-rebase(v1.24):source=d7ecbd903e2

UPSTREAM: 89885: SQUASH: Retry fetching clouds.conf

The OpenStack secret is not guaranteed to be present at the time
kube-controller-manager is initialised.

Co-authored-by: Martin André <m.andre@redhat.com>
Co-authored-by: Pierre Prinetti <pierreprinetti@redhat.com>

openshift-rebase(v1.24):source=8bc9dd29ef0

UPSTREAM: 89885: Fix panic in openstack.InstanceExistsByProviderID()

... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
soltysh pushed a commit to soltysh/kubernetes that referenced this pull request Sep 1, 2022
… secret

This patch brings back the downstream changes that were introduced
to allow reading openstack cloud provider config from a secret.
They are available in release-4.4, but were reverted in master with
openshift/origin#24719

This change includes:

- Ability to read metadata values for kubelet. Since the service
does not have access to the secret to read the configuration, but
it needs data to download (e.g. hostname or flavor), we are trying
to get it from the metadata server.

- Deprecation of kubeConfig parameter. Now we read the file that
was provided with --kubeconfig option.

Origin-commit: f95edc26155a29769b3c5b80c03755a01a87b5fc

UPSTREAM: 89885: legacy-cloud-provider/openstack: include / prefix in instance ID output

When we want to read an instance ID from the metadata service, cloud provider
doesn't include "/" prefix, which is required for successful parsing of
provider the ID later.
This commit adds the missing "/" prefix to the output.

UPSTREAM: 89885: SQUASH: Fix Cinder provisioning crashing on nil cloud provider

OpenStack cloud provider must not use nil when provisioning a Cinder
volume.

UPSTREAM: 89885: SQUASH: Report OpenStack cloud initialization errors

openshift-rebase(v1.24):source=dbe70e455ee

UPSTREAM: <carry>: Set informer for openstack

Set informer for the openstack cloud provider to ensure it is properly
initialized when reading config from a secret.

Upstream 89885 was closed in favor of 96750.

Co-authored-by: Hemant Kumar <hekumar@redhat.com>

openshift-rebase(v1.24):source=d7ecbd903e2

UPSTREAM: 89885: SQUASH: Retry fetching clouds.conf

The OpenStack secret is not guaranteed to be present at the time
kube-controller-manager is initialised.

Co-authored-by: Martin André <m.andre@redhat.com>
Co-authored-by: Pierre Prinetti <pierreprinetti@redhat.com>

openshift-rebase(v1.24):source=8bc9dd29ef0

UPSTREAM: 89885: Fix panic in openstack.InstanceExistsByProviderID()

... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
soltysh pushed a commit to soltysh/kubernetes that referenced this pull request Sep 15, 2022
… secret

This patch brings back the downstream changes that were introduced
to allow reading openstack cloud provider config from a secret.
They are available in release-4.4, but were reverted in master with
openshift/origin#24719

This change includes:

- Ability to read metadata values for kubelet. Since the service
does not have access to the secret to read the configuration, but
it needs data to download (e.g. hostname or flavor), we are trying
to get it from the metadata server.

- Deprecation of kubeConfig parameter. Now we read the file that
was provided with --kubeconfig option.

Origin-commit: f95edc26155a29769b3c5b80c03755a01a87b5fc

UPSTREAM: 89885: legacy-cloud-provider/openstack: include / prefix in instance ID output

When we want to read an instance ID from the metadata service, cloud provider
doesn't include "/" prefix, which is required for successful parsing of
provider the ID later.
This commit adds the missing "/" prefix to the output.

UPSTREAM: 89885: SQUASH: Fix Cinder provisioning crashing on nil cloud provider

OpenStack cloud provider must not use nil when provisioning a Cinder
volume.

UPSTREAM: 89885: SQUASH: Report OpenStack cloud initialization errors

openshift-rebase(v1.24):source=dbe70e455ee

UPSTREAM: <carry>: Set informer for openstack

Set informer for the openstack cloud provider to ensure it is properly
initialized when reading config from a secret.

Upstream 89885 was closed in favor of 96750.

Co-authored-by: Hemant Kumar <hekumar@redhat.com>

openshift-rebase(v1.24):source=d7ecbd903e2

UPSTREAM: 89885: SQUASH: Retry fetching clouds.conf

The OpenStack secret is not guaranteed to be present at the time
kube-controller-manager is initialised.

Co-authored-by: Martin André <m.andre@redhat.com>
Co-authored-by: Pierre Prinetti <pierreprinetti@redhat.com>

openshift-rebase(v1.24):source=8bc9dd29ef0

UPSTREAM: 89885: Fix panic in openstack.InstanceExistsByProviderID()

... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
soltysh pushed a commit to soltysh/kubernetes that referenced this pull request Sep 20, 2022
… secret

This patch brings back the downstream changes that were introduced
to allow reading openstack cloud provider config from a secret.
They are available in release-4.4, but were reverted in master with
openshift/origin#24719

This change includes:

- Ability to read metadata values for kubelet. Since the service
does not have access to the secret to read the configuration, but
it needs data to download (e.g. hostname or flavor), we are trying
to get it from the metadata server.

- Deprecation of kubeConfig parameter. Now we read the file that
was provided with --kubeconfig option.

Origin-commit: f95edc26155a29769b3c5b80c03755a01a87b5fc

UPSTREAM: 89885: legacy-cloud-provider/openstack: include / prefix in instance ID output

When we want to read an instance ID from the metadata service, cloud provider
doesn't include "/" prefix, which is required for successful parsing of
provider the ID later.
This commit adds the missing "/" prefix to the output.

UPSTREAM: 89885: SQUASH: Fix Cinder provisioning crashing on nil cloud provider

OpenStack cloud provider must not use nil when provisioning a Cinder
volume.

UPSTREAM: 89885: SQUASH: Report OpenStack cloud initialization errors

openshift-rebase(v1.24):source=dbe70e455ee

UPSTREAM: <carry>: Set informer for openstack

Set informer for the openstack cloud provider to ensure it is properly
initialized when reading config from a secret.

Upstream 89885 was closed in favor of 96750.

Co-authored-by: Hemant Kumar <hekumar@redhat.com>

openshift-rebase(v1.24):source=d7ecbd903e2

UPSTREAM: 89885: SQUASH: Retry fetching clouds.conf

The OpenStack secret is not guaranteed to be present at the time
kube-controller-manager is initialised.

Co-authored-by: Martin André <m.andre@redhat.com>
Co-authored-by: Pierre Prinetti <pierreprinetti@redhat.com>

openshift-rebase(v1.24):source=8bc9dd29ef0

UPSTREAM: 89885: Fix panic in openstack.InstanceExistsByProviderID()

... when provider is uninitialised.

This is a fix to downstream-only code which was originally proposed
upstream as kubernetes#89885 but did
not merge. It is therefore not relevant upstream. Given that we will
replace the openstack legacy cloud provider in 4.12 we will not
re-propose kubernetes#89885 or this fix to it.

Causes all openstack.Instances() methods which require more than the
local metadata service to return NotImplemented instead of crashing if
the provider is not initialised.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cloudprovider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. 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.

None yet

7 participants