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

[Lambda] Support Drift Detection for Lambda #5186

Merged
merged 5 commits into from
Sep 5, 2024
Merged

Conversation

t-kikuc
Copy link
Member

@t-kikuc t-kikuc commented Sep 4, 2024

What this PR does / why we need it:

Supported DriftDetection for Lambda

When OutOfSync:
image

Restrictions:

  • The following fields in function.yaml are ignored because livestates don't have them.
    • source
    • s3Bucket
    • s3Key
    • s3ObjectVersion

Which issue(s) this PR fixes:

Fixes #5182

Does this PR introduce a user-facing change?: Users can see drifts.

  • How are users affected by this change: N/A
  • Is this breaking change: no
  • How to migrate (if breaking change): no

Note:

To use this feature, users need to add the following IAM Actions to their Piped's IAM Role.

Later I'll describe the details in another PR.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 5.97610% with 236 lines in your changes missing coverage. Please review.

Project coverage is 22.85%. Comparing base (adf2c51) to head (be00911).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
pkg/app/piped/driftdetector/lambda/detector.go 6.38% 220 Missing ⚠️
pkg/app/piped/driftdetector/detector.go 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5186      +/-   ##
==========================================
- Coverage   22.93%   22.85%   -0.09%     
==========================================
  Files         419      420       +1     
  Lines       44986    45247     +261     
==========================================
+ Hits        10318    10340      +22     
- Misses      33873    34111     +238     
- Partials      795      796       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ffjlabo
ffjlabo previously approved these changes Sep 4, 2024
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

I commented about sorting maps.
I think the code I commented on is not needed because it does not work as expected, but the test you wrote is passed.

Comment on lines 263 to 276
// sortMap sorts the given map by keys and returns a new map.
func sortMap(m map[string]string) map[string]string {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
slices.Sort(keys)

sorted := make(map[string]string)
for _, k := range keys {
sorted[k] = m[k]
}
return sorted
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The for-range for map[string]string is always looped in random order.
So, this code may not work as expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

I understood, what a meaningless code... 😅
let me re-think...

Copy link
Member Author

Choose a reason for hiding this comment

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

@Warashi
Thank you, I removed the unnecessary sort. be00911

Some slices need to be sorted, but maps do NOT need to be sorted.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Copy link
Contributor

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

LGTM

@t-kikuc
Copy link
Member Author

t-kikuc commented Sep 5, 2024

@ffjlabo Would you please review again?

This is the only one change: #5186 (comment)

@ffjlabo
Copy link
Member

ffjlabo commented Sep 5, 2024

Sorry for the rough review🙏
I rechecked the new fix. It is fine.

Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

🚀

@t-kikuc t-kikuc merged commit 43c8da8 into master Sep 5, 2024
13 of 17 checks passed
@t-kikuc t-kikuc deleted the lambda-driftdetection branch September 5, 2024 09:16
@github-actions github-actions bot mentioned this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/go kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lambda] Support Drift Detection for Lambda
3 participants