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

Removes CEP subresource. #15632

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/k8s/apis/cilium.io/client/crds/v2/ciliumendpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ spec:
type: object
served: true
storage: true
subresources:
status: {}
subresources: {}
status:
acceptedNames:
kind: ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/apis/cilium.io/v2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
//
// Maintainers: Run ./Documentation/check-crd-compat-table.sh for each release
// Developers: Bump patch for each change in the CRD schema.
CustomResourceDefinitionSchemaVersion = "1.23.1"
CustomResourceDefinitionSchemaVersion = "1.23.2"

// CustomResourceDefinitionSchemaVersionKey is key to label which holds the CRD schema version
CustomResourceDefinitionSchemaVersionKey = "io.cilium.k8s.crd.schema.version"
Expand Down
1 change: 0 additions & 1 deletion pkg/k8s/apis/cilium.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
// +kubebuilder:printcolumn:JSONPath=".status.state",description="Endpoint current state",name="Endpoint State",type=string
// +kubebuilder:printcolumn:JSONPath=".status.networking.addressing[0].ipv4",description="Endpoint IPv4 address",name="IPv4",type=string
// +kubebuilder:printcolumn:JSONPath=".status.networking.addressing[0].ipv6",description="Endpoint IPv6 address",name="IPv6",type=string
// +kubebuilder:subresource:status
// +kubebuilder:storageversion

// CiliumEndpoint is the status of a Cilium policy rule.
Expand Down
42 changes: 4 additions & 38 deletions pkg/k8s/watchers/endpointsynchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (epSync *EndpointSynchronizer) RunK8sCiliumEndpointSync(e *endpoint.Endpoin
// label based selection for CiliumEndpoints.
Labels: pod.GetObjectMeta().GetLabels(),
},
Status: *mdl,
}
localCEP, err = ciliumClient.CiliumEndpoints(namespace).Create(ctx, cep, meta_v1.CreateOptions{})
if err != nil {
Expand All @@ -204,6 +205,8 @@ func (epSync *EndpointSynchronizer) RunK8sCiliumEndpointSync(e *endpoint.Endpoin
// We return earlier for all error cases so we don't need
// to init the local endpoint in non-error cases.
needInit = false
lastMdl = mdl
return nil
}
// We have no localCEP copy. We need to fetch it for updates, below.
// This is unexpected as there should be only 1 writer per CEP, this
Expand Down Expand Up @@ -255,8 +258,7 @@ func (epSync *EndpointSynchronizer) RunK8sCiliumEndpointSync(e *endpoint.Endpoin
ctx, podName,
types.JSONPatchType,
createStatusPatch,
meta_v1.PatchOptions{},
"status")
meta_v1.PatchOptions{})

// Handle Update errors or return successfully
switch {
Expand All @@ -267,42 +269,6 @@ func (epSync *EndpointSynchronizer) RunK8sCiliumEndpointSync(e *endpoint.Endpoin
needInit = true
return nil

case err != nil && k8serrors.IsNotFound(err):
scopedLog.WithError(err).Warn("Cannot update CEP via subresource, trying direct patch")
// Tries to update CEP without specifying `status` as subresource.
localCEP, err = ciliumClient.CiliumEndpoints(namespace).Patch(
ctx, podName,
types.JSONPatchType,
createStatusPatch,
meta_v1.PatchOptions{})
// Handle Update errors or return successfully
switch {
// Return no error when we see a conflict. We want to retry without a
// backoff and the Update* calls returned the current localCEP
case err != nil && k8serrors.IsConflict(err):
scopedLog.WithError(err).Warn("Cannot update CEP due to a revision conflict. The next controller execution will try again")
needInit = true
return nil

// Ensure we re-init when we see a generic error. This will recrate the
// CEP.
case err != nil:
// Suppress logging an error if ep backing the pod was terminated
// before CEP could be updated and shut down the controller.
if errors.Is(err, context.Canceled) {
return nil
}
scopedLog.WithError(err).Error("Cannot update CEP")

needInit = true
return err

// A successful update means no more updates unless the endpoint status, aka mdl, changes
default:
lastMdl = mdl
return nil
}

// Ensure we re-init when we see a generic error. This will recrate the
// CEP.
case err != nil:
Expand Down