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

[Containerapp] Support debug console #7945

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

fangjian0423
Copy link
Contributor

Feature doc: https://github.com/serverless-paas-balam/k4apps/discussions/4846

Some cases:

az containerapp debug --name {containerappname} --resource-group {rg}
az containerapp debug --name {containerappname} --resource-group {rg} --revision {revision_name}
az containerapp debug --name {containerappname} --resource-group {rg} --revision {revision_name} --replica {replica_name}
az containerapp debug --name {containerappname} --resource-group {rg} --revision {revision_name} --replica {replica_name} --container {container_name}

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copy link

azure-client-tools-bot-prd bot commented Sep 4, 2024

⚠️Azure CLI Extensions Breaking Change Test
⚠️containerapp
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd containerapp debug cmd containerapp debug added

Copy link

Hi @fangjian0423,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Sep 4, 2024

Containerapp

@Greedygre
Copy link
Contributor

Greedygre commented Sep 11, 2024

image
I got this error When testing, if it is expected, please provide a friendly message to guide the user.

@Greedygre
Copy link
Contributor

Recommend title:
[Containerapp] az containerapp debug: Support debug console

return ""

def _get_url(self, cmd, resource_group_name, name, revision, replica, container, startup_command):
containers = ContainerAppPreviewClient.get_replica(cmd,
Copy link

Choose a reason for hiding this comment

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

is it possible to reuse the replica data we already loaded? seems like this will do another http call which is not that necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the replica data we already loaded is in validation phase, seems it can't be reused here.

except Exception as e:
stringErr = str(e)
if "Handshake status 400 Bad Request" in stringErr:
raise CLIInternalError("Debug Console feature is not allowed for the subscription.")
Copy link

Choose a reason for hiding this comment

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

400 doesnt necessarily mean a feature flag issue. might be better to show detailed error messages or have an error code mapping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the python websocket library didn't read response body if response code is not in (301, 302, 303 and 101). So we can't read the body and only can read 400 reponse code.

Given we will remove feature flag in the future, let me remove this logic.

Copy link
Contributor Author

@fangjian0423 fangjian0423 Sep 20, 2024

Choose a reason for hiding this comment

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

BTW, the newest websocket client support get response body: https://github.com/websocket-client/websocket-client/blob/master/websocket/_handshake.py#L146 . It is possible to upgrade websocket client in azure-cli-extension?



def _set_debug_defaults(cmd, namespace):
app = ContainerAppPreviewClient.show(cmd, namespace.resource_group_name, namespace.name)
Copy link

Choose a reason for hiding this comment

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

we can list revisions here and see: 1) if we got 404 error or None object then the container app doesnt exist 2) if we got an empty array then the container app exists but doesnt have any revisions
and the revision list data could be reused in checking user input parameter "targetContainer"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO. List revisions will return all revision, this is not a good choice. If customer has lots of revisions, the payload will be big enough.

Copy link

Choose a reason for hiding this comment

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

normally the number of revisions in a single container app wont be too much. currently only 3.7% of container apps are in multiple active revision mode.
btw if you take a closer look at the container app payload and revision payload you will see container app is much larger than just a revision.

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 seems this API will return all the revisions, which are active or not active.

@fangjian0423
Copy link
Contributor Author

image I got this error When testing, if it is expected, please provide a friendly message to guide the user.

we have a discussion here: #7945 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot ContainerApp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants