Skip to content

Commit

Permalink
endpoint: don't create endpoint with labels
Browse files Browse the repository at this point in the history
When endpoint is created and `EndpointChangeRequest`
contains labels, it might cause the endpoint regeneration to not be
triggered as it is only triggered when labels are changed.
Unfortunately this does not happen when epTemplate.Labels are set
with the same labels as `EndpointChangeRequest`.

This commit fixes the above issue by not setting epTemplate.Labels.

Fixes: cilium#29776

Signed-off-by: Ondrej Blazek <ondrej.blazek@firma.seznam.cz>
  • Loading branch information
oblazek authored and aanm committed Feb 21, 2024
1 parent 0765ddf commit cb15333
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion daemon/cmd/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ func (d *Daemon) createEndpoint(ctx context.Context, owner regeneration.Owner, e
"sync-build": epTemplate.SyncBuildEndpoint,
}).Info("Create endpoint request")

// We don't need to create the endpoint with the labels. This might cause
// the endpoint regeneration to not be triggered further down, with the
// ep.UpdateLabels or the ep.RunMetadataResolver, because the regeneration
// is only triggered in case the labels are changed, which they might not
// change because NewEndpointFromChangeModel would contain the
// epTemplate.Labels, the same labels we would be calling ep.UpdateLabels or
// the ep.RunMetadataResolver.
apiLabels := labels.NewLabelsFromModel(epTemplate.Labels)
epTemplate.Labels = nil

ep, err := endpoint.NewEndpointFromChangeModel(d.ctx, owner, d, d.ipcache, d.l7Proxy, d.identityAllocator, epTemplate)
if err != nil {
return invalidDataError(ep, fmt.Errorf("unable to parse endpoint parameters: %s", err))
Expand Down Expand Up @@ -414,7 +424,6 @@ func (d *Daemon) createEndpoint(ctx context.Context, owner regeneration.Owner, e
return invalidDataError(ep, err)
}

apiLabels := labels.NewLabelsFromModel(epTemplate.Labels)
infoLabels := labels.NewLabelsFromModel([]string{})

if len(apiLabels) > 0 {
Expand Down

0 comments on commit cb15333

Please sign in to comment.