-
Notifications
You must be signed in to change notification settings - Fork 332
fix: read unified azure.yaml in agent run and deploy #9149
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
Open
huimiu
wants to merge
6
commits into
main
Choose a base branch
from
hui/unified-config-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ce8720
fix: resolve unified agent runtime configuration
huimiu ebdaf92
fix: keep core environment schemas unchanged
huimiu b931817
fix: keep agent environment schemas unchanged
huimiu d6edea1
fix: remove unsupported workflow handling
huimiu f8ebf63
chore: begin merge conflict resolution with main
Copilot 685ecc3
fix: resolve PR 9149 merge conflicts
huimiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,18 +58,25 @@ func preprovisionHandler(ctx context.Context, azdClient *azdext.AzdClient, args | |
| ctx, | ||
| azdClient, | ||
| args.Project.Services, | ||
| args.Project.Path, | ||
| ); err != nil { | ||
| return err | ||
| } | ||
| connections, err := collectConnections(args.Project.Services) | ||
| connections, err := collectConnections( | ||
| args.Project.Services, | ||
| args.Project.Path, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| for _, svc := range args.Project.Services { | ||
| switch svc.Host { | ||
| case AiAgentHost: | ||
| if err := populateContainerSettings(ctx, azdClient, svc); err != nil { | ||
| if err := prepareContainerSettings( | ||
| svc, | ||
| args.Project.Path, | ||
| ); err != nil { | ||
|
huimiu marked this conversation as resolved.
|
||
| return fmt.Errorf("failed to populate container settings for service %q: %w", svc.Name, err) | ||
| } | ||
| if err := envUpdate( | ||
|
|
@@ -167,8 +174,12 @@ func updateLegacyProjectDeployments( | |
| ctx context.Context, | ||
| azdClient *azdext.AzdClient, | ||
| services map[string]*azdext.ServiceConfig, | ||
| projectRoot string, | ||
| ) error { | ||
| deployments, err := collectLegacyProjectDeployments(services) | ||
| deployments, err := collectLegacyProjectDeployments( | ||
| services, | ||
| projectRoot, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -221,15 +232,22 @@ func predeployHandler(ctx context.Context, azdClient *azdext.AzdClient, args *az | |
| ctx, | ||
| azdClient, | ||
| args.Project.Services, | ||
| args.Project.Path, | ||
| ); err != nil { | ||
| return err | ||
| } | ||
| connections, err := collectConnections(args.Project.Services) | ||
| connections, err := collectConnections( | ||
| args.Project.Services, | ||
| args.Project.Path, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := populateContainerSettings(ctx, azdClient, svc); err != nil { | ||
| if err := prepareContainerSettings( | ||
| svc, | ||
| args.Project.Path, | ||
| ); err != nil { | ||
| return fmt.Errorf("failed to populate container settings for service %q: %w", svc.Name, err) | ||
| } | ||
| if err := envUpdate( | ||
|
|
@@ -738,10 +756,37 @@ func setEnvVar(ctx context.Context, azdClient *azdext.AzdClient, envName string, | |
| return nil | ||
| } | ||
|
|
||
| func populateContainerSettings(ctx context.Context, azdClient *azdext.AzdClient, svc *azdext.ServiceConfig) error { | ||
| func prepareContainerSettings( | ||
| svc *azdext.ServiceConfig, | ||
| projectRoot string, | ||
| ) error { | ||
| rawAdditional := svc.GetAdditionalProperties() | ||
| rawConfig := svc.GetConfig() | ||
| hasRootFileRef := rawAdditional != nil && | ||
| rawAdditional.GetFields()["$ref"] != nil || | ||
| rawConfig != nil && rawConfig.GetFields()["$ref"] != nil | ||
| if hasRootFileRef { | ||
| if err := project.ResolveServiceConfigInPlace( | ||
| svc, | ||
| projectRoot, | ||
| ); err != nil { | ||
| return fmt.Errorf( | ||
| "failed to resolve agent config: %w", | ||
| err, | ||
| ) | ||
| } | ||
| } else if err := project.NormalizeServiceConfigInPlace(svc); err != nil { | ||
|
trangevi marked this conversation as resolved.
|
||
| return fmt.Errorf( | ||
| "failed to normalize agent config: %w", | ||
| err, | ||
| ) | ||
| } | ||
| foundryAgentConfig, err := project.LoadServiceTargetAgentConfig(svc) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to parse foundry agent config: %w", err) | ||
| return fmt.Errorf( | ||
| "failed to parse foundry agent config: %w", | ||
| err, | ||
| ) | ||
| } | ||
|
|
||
| // Resolve the container resources, applying defaults when unset. | ||
|
|
@@ -760,19 +805,15 @@ func populateContainerSettings(ctx context.Context, azdClient *azdext.AzdClient, | |
| result.Cpu = project.DefaultCpu | ||
| } | ||
|
|
||
| // Persist the resolved container settings back onto the service's inline | ||
| // properties, preserving the agent definition and other config keys. | ||
| if err := project.SetAgentContainerSettings(svc, &project.ContainerSettings{Resources: result}); err != nil { | ||
| return fmt.Errorf("failed to update agent container settings: %w", err) | ||
| } | ||
|
|
||
| // Need to add the service config back to the project for use further down the pipeline | ||
| req := &azdext.AddServiceRequest{Service: svc} | ||
|
|
||
| if _, err := azdClient.Project().AddService(ctx, req); err != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer necessary? |
||
| return fmt.Errorf("adding agent service to project: %w", err) | ||
| if err := project.SetAgentContainerSettings( | ||
| svc, | ||
| &project.ContainerSettings{Resources: result}, | ||
| ); err != nil { | ||
| return fmt.Errorf( | ||
| "failed to update agent container settings: %w", | ||
| err, | ||
| ) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should be moved into the extension specific cspell, will remove the need for azd core codeowners approval