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

Wip/fix get harvester kubeconfig #1628

Merged

Conversation

m-ildefons
Copy link
Contributor

Which issue(s) this PR fixes:

Issue # #1627

What this PR does / why we need it:

Creating a cloud credential from a kubeconfig file that has not been created through Rancher is wrong, because then Rancher can't determine the expiration date of that kubeconfig and will return an error.
To fix this, the test suite needs to create the kubeconfig file through Rancher

Special notes for your reviewer:

Additional documentation or context

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
Fix generate kubeconfig function: fix oder of keyword parameters.

Add debug logging (use with pytest `-v -s` options)

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
@m-ildefons m-ildefons merged commit 48291a3 into harvester:main Nov 5, 2024
4 checks passed
Copy link
Member

@lanfon72 lanfon72 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 all changes are not harmful, but could you ask QAs to review PR rather than engineers next time?

and also cc @khushboo-rancher for your PR would be nice.

@@ -67,19 +67,27 @@ def __repr__(self):

def _get(self, path, **kwargs):
url = urljoin(self.endpoint, path)
return self.session.get(url, **kwargs)
resp = self.session.get(url, **kwargs)
print(f"{resp.request.method} {resp.request.url}")
Copy link
Member

Choose a reason for hiding this comment

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

please remove the test output.

@@ -678,6 +678,7 @@ def delete(self, name, *, raw=False):

class ClusterManager(BaseManager):
PATH_fmt = "v3/cluster/{uid}"
PATH1_fmt = "v3/clusters/{uid}"
Copy link
Member

Choose a reason for hiding this comment

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

it looks we didn't use this, is there any reason to add it?

@@ -15,7 +15,9 @@ def __init__(self):

def _storage_net_configured(self):
code, data = self.settings.get('storage-network')
if (cs := data.get('status', {}).get('conditions')):
Copy link
Member

Choose a reason for hiding this comment

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

The assignment expressions (:=) is introduced in python 3.8, which is the version we targeting to support, is there any reason to replace it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not supported in Python 3.6. We maintain a Python 3.6 environment in our tox config. Either we drop that as well, or we stick to Python 3.6 compatibility.

@@ -130,7 +130,14 @@ def harvester_mgmt_cluster(api_client, rancher_api_client, unique_name, polling_
@pytest.fixture(scope='module')
def harvester_cloud_credential(api_client, rancher_api_client,
harvester_mgmt_cluster, unique_name):
harvester_kubeconfig = api_client.generate_kubeconfig()
code, data = rancher_api_client.clusters.generate_kubeconfig(
Copy link
Member

Choose a reason for hiding this comment

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

I think the two configurations are same, could you check with @albinsun about the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are not the same. One uses Rancher's API endpoint and authenticates with a Rancher token and the other one uses Harvester's API endpoint directly.
For these tests we need to use Rancher's API endpoint.
Please read the issue linked up top.

@m-ildefons
Copy link
Contributor Author

I think all changes are not harmful, but could you ask QAs to review PR rather than engineers next time?

Your review was requested nearly a week ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants