Skip to content

Commit

Permalink
fix: allow generation handler to update observed generation
Browse files Browse the repository at this point in the history
The alias handler was updating the observed generation, which was
causing API fields to appear when they should not.

Additionally, ensure all aliased objects have the observed generation
handler.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Jan 3, 2025
1 parent e184c2c commit 68d565f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/controller/handlers/alias/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func AssignAlias(req router.Request, resp router.Response) (err error) {
if aliasable.GetAliasName() == "" {
if aliasable.IsAssigned() || aliasable.GetGeneration() != aliasable.GetObservedGeneration() {
aliasable.SetAssigned(false)
aliasable.SetObservedGeneration(aliasable.GetGeneration())
return req.Client.Status().Update(req.Ctx, req.Object)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (c *Controller) setupRoutes() error {
root.Type(&v1.Webhook{}).HandlerFunc(cleanup.Cleanup)
root.Type(&v1.Webhook{}).HandlerFunc(alias.AssignAlias)
root.Type(&v1.Webhook{}).HandlerFunc(webHooks.SetSuccessRunTime)
root.Type(&v1.Webhook{}).HandlerFunc(generationed.UpdateObservedGeneration)

// Cronjobs
root.Type(&v1.CronJob{}).HandlerFunc(cleanup.Cleanup)
Expand All @@ -136,6 +137,7 @@ func (c *Controller) setupRoutes() error {
// OAuthApps
root.Type(&v1.OAuthApp{}).HandlerFunc(cleanup.Cleanup)
root.Type(&v1.OAuthApp{}).HandlerFunc(alias.AssignAlias)
root.Type(&v1.OAuthApp{}).HandlerFunc(generationed.UpdateObservedGeneration)

// OAuthAppLogins
root.Type(&v1.OAuthAppLogin{}).HandlerFunc(cleanup.Cleanup)
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/apis/otto.otto8.ai/v1/oauthapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
_ fields.Fields = (*OAuthApp)(nil)
_ fields.Fields = (*OAuthAppLogin)(nil)
_ Aliasable = (*OAuthApp)(nil)
_ Generationed = (*OAuthApp)(nil)
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/apis/otto.otto8.ai/v1/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
var (
_ Aliasable = (*Webhook)(nil)
_ fields.Fields = (*Webhook)(nil)
_ Generationed = (*Webhook)(nil)
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down

0 comments on commit 68d565f

Please sign in to comment.