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

Fix az aks get-credentials on Windows #4762

Merged
merged 2 commits into from
Nov 8, 2017

Conversation

mboersma
Copy link
Member

NamedTemporaryFile can't be opened more than once on Windows, so this uses mkstemp. Tested interactively on Windows 10, macOS, and Ubuntu Linux.

@derekbekoe
Copy link
Member

Should update HISTORY.rst with description of fix.

@mboersma mboersma force-pushed the fix-windows-get-creds branch from 572d716 to 8d055d5 Compare October 25, 2017 21:04
Copy link

@rbigeard rbigeard left a comment

Choose a reason for hiding this comment

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

I have tested the change brought by this PR on Powershell on Windows 10 and it fixes the original issue

@derekbekoe
Copy link
Member

@mboersma There's a conflict after a prev. PR merge.

@@ -1295,13 +1295,17 @@ def aks_get_credentials(client, resource_group_name, name, admin=False,
pass

# merge the new kubeconfig into the existing one
with tempfile.NamedTemporaryFile(mode='w+t') as additional_file:
fd, temp_path = tempfile.mkstemp()
additional_file = os.fdopen(fd, 'w+t')
Copy link
Contributor

Choose a reason for hiding this comment

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

t is not necessary as text mode is the default, but if you prefer explicit, that is fine

logger.warning('Failed to merge credentials to kube config file: %s', ex)
finally:
additional_file.close()
os.remove(temp_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you add a couple of tests for this logic. The related issue impacts quite a few users, so good to build up regression tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, a bit straightforward option is to pass the content to merge_kubernetes_configurations rather build up a temp file and gets read out again. Of course this requires some refactor on old code, so up to you.

@derekbekoe derekbekoe added the ACS az acs/aks/openshift label Oct 26, 2017
@mboersma
Copy link
Member Author

I'll write some unit tests and rebase this.

@mboersma mboersma changed the title Fix az aks get-credentials on Windows [WIP] Fix az aks get-credentials on Windows Nov 2, 2017
@derekbekoe
Copy link
Member

@mboersma FYI code freeze for next release is 11/8.
cc: @yugangw-msft @troydai

@mboersma mboersma force-pushed the fix-windows-get-creds branch from 8d055d5 to 11fea79 Compare November 6, 2017 23:50
@troydai
Copy link
Contributor

troydai commented Nov 7, 2017

@mboersma is this PR still work in progress?

@mboersma
Copy link
Member Author

mboersma commented Nov 7, 2017

@troydai I want to add tests, but I realized there are already good unit tests around the underlying _merge_kubernetes_configurations function. So I added az aks get-credentials scenario tests.

But AKS has been so popular we're fighting capacity issues right now, and I've been unable to re-run the scenario test despite trying in the background all day long: Allocation failed.

So I'd really like to see this merged because I know it fixes an issue on Windows, but I'm having trouble adding a get-credentials test currently. I would be glad to follow on with a PR that adds those tests if that's acceptable to you so we can get this merged, and in the meantime I'll continue to try to get the scenario test to succeed.

@mboersma mboersma changed the title [WIP] Fix az aks get-credentials on Windows Fix az aks get-credentials on Windows Nov 7, 2017
@troydai
Copy link
Contributor

troydai commented Nov 8, 2017

Okie Dokie. I will merge this PR. I'm interested to know the capacity issue since we'd like to run automation against live environment routinely as well.

@troydai troydai merged commit e6d3f3c into Azure:dev Nov 8, 2017
@mboersma mboersma deleted the fix-windows-get-creds branch November 8, 2017 16:05
@BlitzkriegSoftware
Copy link

When will this be shipped?

2 similar comments
@BlitzkriegSoftware
Copy link

When will this be shipped?

@BlitzkriegSoftware
Copy link

When will this be shipped?

@troydai troydai added this to the Sprint 26- Connect() milestone Nov 8, 2017
@troydai
Copy link
Contributor

troydai commented Nov 8, 2017

I will be released on 11/15.

LukaszStem pushed a commit to LukaszStem/azure-cli that referenced this pull request Nov 9, 2017
vmss: support basic tier of vms (Azure#4847)

Azure IoT CA functionality (Azure#4804)

* Adds support for X.509 Certificates in IoT Hub.

* Modifies release notes and changes help link.

* Cleans up .gitignore, and HISTORY.rst. Passes a single factory in commands.py. Moves test utilities. Adds a file completer.

* Updates style after rebase based on additional linter restrictions.

Reserved Instance cli public PR (Azure#4838)

Handle dashes in extension names better (Azure#4839)

Fix `az aks get-credentials` on Windows (Azure#4762)

* Fix `az aks get-credentials` on Windows

* Move k8s file merge logic to helper function

appservice: support assign managed service identity to webapp/functionapp (Azure#4837)

Extension examples small improvement (Azure#4852)

Fixing appservice list-locations (Azure#4846)

Add extension name to telemetry and UA header (Azure#4854)

Fix Azure#4825. (Azure#4853)

Extensions `az extension add` --yes param as flag (Azure#4858)

Fix issue Azure#2752. (Azure#4859)
@haroldrandom haroldrandom added the ACS az acs/aks/openshift label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACS az acs/aks/openshift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants