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: fix incorrect .Is() method on update skipped due to backoff error #4213

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Jun 23, 2023

What this PR does / why we need it:

This fixes an issue where KIC crash due to a stack overflow when a broken config is applied in dbmode.

The problematic piece was:

func (e ErrUpdateSkippedDueToBackoffStrategy) Is(err error) bool {
	return errors.Is(err, ErrUpdateSkippedDueToBackoffStrategy{})
}

which didn't work as intended. .Is() is meant to compare errors, as in compare their values, not types.

Where this was called we intended to check the type of an error, not it's value.

The stack overflow is prevent by removing the .Is() method from UpdateSkippedDueToBackoffStrategyError as it's not needed now.

The test that failed due to a stack overflow before this change was introduced and passes now:

	skippedErr := sendconfig.NewUpdateSkippedDueToBackoffStrategyError("reason")

	t.Run("errors.Is()", func(t *testing.T) {
		assert.False(t,
			errors.Is(skippedErr, deckerrors.ConfigConflictError{
				Err: sendconfig.NewUpdateSkippedDueToBackoffStrategyError("different reason"),
			}),
			"shouldn't panic when using errors.Is() with NewUpdateSkippedDueToBackoffStrategyError",
		)
	})

Which issue this PR fixes:

Fixes: #4212

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@pmalek pmalek self-assigned this Jun 23, 2023
@pmalek pmalek force-pushed the fix-error-unwrapping-for-skipped-due-to-backoff-error branch from 53b2a4a to 76f1a3c Compare June 23, 2023 10:34
@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Patch coverage: 50.0% and project coverage change: -0.1 ⚠️

Comparison is base (7f4ab19) 62.6% compared to head (76f1a3c) 62.5%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #4213     +/-   ##
=======================================
- Coverage   62.6%   62.5%   -0.1%     
=======================================
  Files        153     153             
  Lines      17008   17006      -2     
=======================================
- Hits       10652   10644      -8     
- Misses      5686    5694      +8     
+ Partials     670     668      -2     
Impacted Files Coverage Δ
internal/dataplane/kong_client.go 66.8% <0.0%> (ø)
internal/dataplane/sendconfig/sendconfig.go 78.3% <0.0%> (ø)
internal/dataplane/sendconfig/backoff_strategy.go 84.6% <75.0%> (+6.0%) ⬆️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pmalek pmalek marked this pull request as ready for review June 23, 2023 11:39
@pmalek pmalek requested a review from a team as a code owner June 23, 2023 11:39
@pmalek pmalek added this to the KIC v2.11.0 milestone Jun 23, 2023
@pmalek pmalek merged commit 96333d8 into main Jun 23, 2023
30 checks passed
@pmalek pmalek deleted the fix-error-unwrapping-for-skipped-due-to-backoff-error branch June 23, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KIC crashes due to stack overflow when broken config is applied in db mode
2 participants