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: do not modify cached GetAgentsResponse #9569

Merged
merged 2 commits into from
Jun 25, 2024
Merged

Conversation

kkunapuli
Copy link
Contributor

@kkunapuli kkunapuli commented Jun 25, 2024

Ticket

RM-350

Description

The Kubernetes resource manager caches the response to a GetAgents request. Return a deep copy of the cached response to prevent unintentionally modifying the cached response.

Test Plan

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

@cla-bot cla-bot bot added the cla-signed label Jun 25, 2024
Copy link

netlify bot commented Jun 25, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit f004433
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/667b2969969c2b0008a44ec1
😎 Deploy Preview https://deploy-preview-9569--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.80%. Comparing base (f1aa1b4) to head (f004433).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9569      +/-   ##
==========================================
- Coverage   49.80%   49.80%   -0.01%     
==========================================
  Files        1247     1247              
  Lines      162241   162249       +8     
  Branches     2888     2887       -1     
==========================================
+ Hits        80803    80806       +3     
- Misses      81266    81271       +5     
  Partials      172      172              
Flag Coverage Δ
backend 43.89% <70.00%> (-0.01%) ⬇️
harness 63.74% <ø> (ø)
web 46.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
master/internal/rm/kubernetesrm/jobs.go 69.66% <100.00%> (-0.09%) ⬇️
...nal/rm/kubernetesrm/kubernetes_resource_manager.go 30.81% <0.00%> (ø)
master/internal/rm/resource_manager_iface.go 77.77% <75.00%> (-22.23%) ⬇️

... and 5 files with indirect coverage changes

@kkunapuli kkunapuli added the to-cherry-pick Pull requests that need to be cherry-picked into the current release label Jun 25, 2024
@kkunapuli kkunapuli marked this pull request as ready for review June 25, 2024 19:23
@kkunapuli kkunapuli requested a review from a team as a code owner June 25, 2024 19:23
return k.jobsService.GetAgents(), nil
resp := k.jobsService.GetAgents()
// Ensure cached response is not inadvertently modified.
return rm.CopyGetAgentsResponse(resp)
Copy link
Contributor

Choose a reason for hiding this comment

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

probably is safer to do this copy on jobsService.getAgents in case someone down the line calls this within the jobs service

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By that do you mean, copy the response before returning from jobsService.GetAgents() ?

I had that originally, but the function signature didn't return an error. Thinking about it, there's no reason I can't update the jobsService function to return an error. :)

@kkunapuli kkunapuli merged commit 8fbed0e into main Jun 25, 2024
81 of 97 checks passed
@kkunapuli kkunapuli deleted the kunapuli/fix-topology-map branch June 25, 2024 21:08
github-actions bot pushed a commit that referenced this pull request Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed to-cherry-pick Pull requests that need to be cherry-picked into the current release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants