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: Ensure shallow copy of data when returning back cached data #6167

Merged
merged 2 commits into from
May 10, 2024

Conversation

jonathan-innis
Copy link
Contributor

@jonathan-innis jonathan-innis commented May 8, 2024

Fixes #N/A

Description

Ensure the slices are shallow copied before returning back cached data from the caller. This ensures if the slice of the data is manipulated by the caller (like sorted), it doesn't affect the original copy that is stored and cached.

This can particularly be a problem when sorts are occurring on the original data in a multi-threaded manner. Because of swaps, this can cause the same data to appear multiple times or to be altered in ways that are inconsistent.

How was this change tested?

make presubmit

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jonathan-innis jonathan-innis requested a review from a team as a code owner May 8, 2024 07:09
@jonathan-innis jonathan-innis requested a review from njtran May 8, 2024 07:09
Copy link

netlify bot commented May 8, 2024

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit 986794a
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/663e63d6bf6c7b0008c3950f

@jonathan-innis jonathan-innis force-pushed the ensure-data-deep-copy branch from 34a69c1 to ead406e Compare May 8, 2024 07:09
@coveralls
Copy link

coveralls commented May 8, 2024

Pull Request Test Coverage Report for Build 9036330896

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 82.28%

Totals Coverage Status
Change from base Build 9034104269: 0.04%
Covered Lines: 5414
Relevant Lines: 6580

💛 - Coveralls

@jonathan-innis jonathan-innis force-pushed the ensure-data-deep-copy branch 8 times, most recently from 001b071 to 74089d3 Compare May 8, 2024 20:39
@jonathan-innis jonathan-innis changed the title fix: Ensure deep copy of data when returning back cached data fix: Ensure shallow copy of data when returning back cached data May 8, 2024
@jonathan-innis jonathan-innis force-pushed the ensure-data-deep-copy branch from 74089d3 to 067ecfd Compare May 8, 2024 20:40
Copy link
Contributor

@njtran njtran left a comment

Choose a reason for hiding this comment

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

LGTM just two questions

pkg/providers/amifamily/suite_test.go Outdated Show resolved Hide resolved
pkg/providers/amifamily/suite_test.go Outdated Show resolved Hide resolved
@jonathan-innis jonathan-innis force-pushed the ensure-data-deep-copy branch from 067ecfd to 1af3a37 Compare May 9, 2024 01:34
@jonathan-innis jonathan-innis enabled auto-merge (squash) May 9, 2024 01:35
Copy link
Contributor Author

@jonathan-innis jonathan-innis left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

Copy link
Contributor

github-actions bot commented May 9, 2024

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:0-1af3a3741b049a596fce6359fb13dd1877a7d4ae.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

helm upgrade --install karpenter oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter --version "0-1af3a3741b049a596fce6359fb13dd1877a7d4ae" --namespace "kube-system" --create-namespace \
  --set "settings.clusterName=${CLUSTER_NAME}" \
  --set "settings.interruptionQueue=${CLUSTER_NAME}" \
  --set controller.resources.requests.cpu=1 \
  --set controller.resources.requests.memory=1Gi \
  --set controller.resources.limits.cpu=1 \
  --set controller.resources.limits.memory=1Gi \
  --wait

@jonathan-innis jonathan-innis force-pushed the ensure-data-deep-copy branch from 1af3a37 to 986794a Compare May 10, 2024 18:13
@jonathan-innis jonathan-innis merged commit 836c1e0 into aws:main May 10, 2024
16 checks passed
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 13, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
jonathan-innis added a commit to jonathan-innis/karpenter-provider-aws that referenced this pull request May 14, 2024
njtran pushed a commit to njtran/karpenter-provider-aws that referenced this pull request May 22, 2024
johngmyers pushed a commit to johngmyers/karpenter that referenced this pull request May 31, 2024
@vitaly-dt
Copy link

vitaly-dt commented Jun 16, 2024

Hi @jonathan-innis
This fix has been communicated by AWS Health Dashboard as a critical fix.
Can you maybe elaborate on what is this pull request solving?

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.

4 participants