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

Report config push failures as Events #3446

Merged
merged 50 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d7963d3
tmp: unreleased go-kong
rainest Dec 1, 2022
ec2d5f6
feat(dataplane) raise Events for config errors
rainest Nov 18, 2022
fa10d73
wip: add tags to translators
rainest Dec 7, 2022
50e7480
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
rainest Jan 25, 2023
7e56ebb
wip: unreleased go-kong
rainest Jan 27, 2023
d6a3288
wip: refactor around new go-kong
rainest Jan 27, 2023
077417b
wip: refactor around all the things
rainest Jan 28, 2023
71266c8
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
rainest Feb 2, 2023
7f44da3
wip: update against revised go-kong
rainest Feb 2, 2023
15e4a1b
wip: remove outdated TODOs
rainest Feb 3, 2023
16eb5dd
wip: update unmarshaling to match final Kong error format
rainest Feb 3, 2023
4eb2a25
wip: change log to debug
rainest Feb 3, 2023
c9879f6
wip: remove outdated TODO
rainest Feb 3, 2023
f48a3bc
wip: remove unnecessary collector
rainest Feb 3, 2023
aa29189
wip: update tests post-refactor in KIC#3444
rainest Feb 3, 2023
c420991
wip: unreleased go-kong
rainest Feb 3, 2023
b352e4d
wip: test gating and assorted cleanup/fixes
rainest Feb 3, 2023
45f7757
wip: odd panic condition comment
rainest Feb 3, 2023
fdfe689
chore(deps) go-kong to 0.37
rainest Feb 3, 2023
4080b65
wip: add flattened errors version gate
rainest Feb 3, 2023
45cf24c
wip: use service parent tags
rainest Feb 4, 2023
f3bf2f0
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
czeslavo Feb 6, 2023
6371a7e
wip: extracted from gojira, left old commented
rainest Feb 6, 2023
99392cf
wip: update units with latest (possibly borked) upstream output
rainest Feb 6, 2023
b26eb72
wip: log version gate for error parsing
rainest Feb 6, 2023
957a53d
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
rainest Feb 7, 2023
2af81ee
wip: service check that doesn't actually check anything yet
rainest Feb 7, 2023
df03571
wip: reorder return signature
rainest Feb 7, 2023
71bb068
wip: add additional event to integration, fix unit
rainest Feb 8, 2023
4403d18
chore: appease the linter
rainest Feb 8, 2023
31cb2b0
wip: use proper version cutoff
rainest Feb 8, 2023
13d4fbf
wip: tune tag generation a bit
rainest Feb 8, 2023
d7432cb
wip: strip tags from parser tests
rainest Feb 8, 2023
3e26393
wip: remove merge garbage
rainest Feb 8, 2023
28dc71b
wip: golangci-lint why
rainest Feb 8, 2023
1a152bf
wip: use correct event reason
rainest Feb 8, 2023
5838da3
wip: align semver checks
rainest Feb 8, 2023
30e6851
wip: update more parser tests
rainest Feb 9, 2023
6a40790
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
rainest Feb 9, 2023
f088562
wip: remove manual cleanup
rainest Feb 10, 2023
4b59854
wip: update CHANGELOG.md
rainest Feb 10, 2023
32b172d
pr: use invalid UUID for placeholder tags
rainest Feb 10, 2023
4056b2b
pr: combine expected and bug if clauses
rainest Feb 10, 2023
d1254be
pr: remove outdated TODO, add whitespace
rainest Feb 10, 2023
a9e8cdb
pr: clarify log language
rainest Feb 10, 2023
d8906f1
pr: add docstring for onUpdateInMemoryMode
rainest Feb 10, 2023
dd88418
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
rainest Feb 10, 2023
0166fee
Merge remote-tracking branch 'origin/main' into feat/flat-error-events
czeslavo Feb 13, 2023
fc81794
Update internal/util/k8s.go
rainest Feb 14, 2023
29d6cc6
pr: add test condition explanation
rainest Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ Adding a new version? You'll need three changes:
that all time series for those metrics will get a new label designating the
address of the dataplane that the configuration push has been targeted for.
[#3521](https:/Kong/kubernetes-ingress-controller/pull/3521)
- In DB-less mode, failure to push a config will now generate Kubernetes Events
with the reason `KongConfigurationApplyFailed` and an `InvolvedObject`
indicating which Kubernetes resource was responsible for the broken Kong
configuration.
[#3446](https:/Kong/kubernetes-ingress-controller/pull/3446)
- Leader election is enabled by default then kong admin service discovery is enabled.
[#3529](https:/Kong/kubernetes-ingress-controller/pull/3529)

Expand Down
5 changes: 4 additions & 1 deletion internal/dataplane/kong_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,18 @@ func (c *KongClient) sendToClient(
// apply the configuration update in Kong
timedCtx, cancel := context.WithTimeout(ctx, c.requestTimeout)
defer cancel()
newConfigSHA, err := sendconfig.PerformUpdate(
newConfigSHA, entityErrors, err := sendconfig.PerformUpdate(
timedCtx,
logger,
client,
config,
targetConfig,
c.prometheusMetrics,
)

c.recordResourceFailureEvents(entityErrors, KongConfigurationApplyFailedEventReason)
sendDiagnostic(err != nil)

if err != nil {
if expired, ok := timedCtx.Deadline(); ok && time.Now().After(expired) {
logger.Warn("exceeded Kong API timeout, consider increasing --proxy-timeout-seconds")
Expand Down
9 changes: 8 additions & 1 deletion internal/dataplane/kongstate/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,49 @@ func (c *Consumer) SanitizedCopy() *Consumer {
}
}

func (c *Consumer) SetCredential(credType string, credConfig interface{}) error {
func (c *Consumer) SetCredential(credType string, credConfig interface{}, tags []*string) error {
switch credType {
case "key-auth", "keyauth_credential":
cred, err := NewKeyAuth(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.KeyAuths = append(c.KeyAuths, cred)
case "basic-auth", "basicauth_credential":
cred, err := NewBasicAuth(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.BasicAuths = append(c.BasicAuths, cred)
case "hmac-auth", "hmacauth_credential":
cred, err := NewHMACAuth(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.HMACAuths = append(c.HMACAuths, cred)
case "oauth2":
cred, err := NewOauth2Credential(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.Oauth2Creds = append(c.Oauth2Creds, cred)
case "jwt", "jwt_secret":
cred, err := NewJWTAuth(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.JWTAuths = append(c.JWTAuths, cred)
case "acl":
cred, err := NewACLGroup(credConfig)
if err != nil {
return err
}
cred.Tags = tags
c.ACLGroups = append(c.ACLGroups, cred)
case "mtls-auth":
if !versions.GetKongVersion().MajorMinorPatchOnly().GTE(versions.MTLSCredentialVersionCutoff) {
Expand All @@ -112,6 +118,7 @@ func (c *Consumer) SetCredential(credType string, credConfig interface{}) error
if err != nil {
return err
}
cred.Tags = tags
c.MTLSAuths = append(c.MTLSAuths, cred)
default:
return fmt.Errorf("invalid credential type: '%v'", credType)
Expand Down
Loading