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

Add status field to policy resource #1317

Merged
merged 7 commits into from
Jan 29, 2021
Merged

Add status field to policy resource #1317

merged 7 commits into from
Jan 29, 2021

Conversation

LorcanMcVeigh
Copy link
Contributor

Proposed changes

This PR adds the status field, with the sub-fields 'state', 'reason' and 'message', to the policy resource.
It also prints out the state of the policy when kubectl get policy <policy-name> is ran.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

internal/k8s/status.go Outdated Show resolved Hide resolved
Copy link

@mikestephen mikestephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a couple of comments, but looking great Lorcan.

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LorcanMcVeigh

We need to consider a few more cases related to leader election:

(1) only report the status from the leader. this is needed so that all Ingress Controller pods don't try to report statuses, but only one, to avoid duplicated work/errors related to collisions of updates.

For example, for VS/VSR, before reporting a status, the following check is performed:

if lbc.reportVsVsrStatusEnabled() {

we need to do a similar check for policies.
we can use that function. Better to rename it so it doesn't apply only for VS/VSR. For example, reportCustomResourceStatusEnabled()

(2) when an Ingress Controller pod becomes the leader, it needs to report statuses of the resources it handles. Otherwise, the resources that were processed during the period when there was no elected leader (can happen during upgrades or when the leader pod fails) will not have the status reported.

We already do that for VirtualServer/VirtualServerRoute and Ingresses. See

OnStartedLeading: func(ctx context.Context) {
For Policies, we simply need to look go through every policy in the lister and report the status based on the validation.

internal/k8s/controller.go Show resolved Hide resolved
internal/k8s/controller.go Outdated Show resolved Hide resolved
internal/k8s/controller.go Outdated Show resolved Hide resolved
pkg/apis/configuration/v1/types.go Outdated Show resolved Hide resolved
internal/k8s/controller.go Outdated Show resolved Hide resolved
internal/k8s/controller.go Outdated Show resolved Hide resolved
internal/k8s/controller.go Outdated Show resolved Hide resolved
@LorcanMcVeigh LorcanMcVeigh merged commit cea9354 into master Jan 29, 2021
@LorcanMcVeigh LorcanMcVeigh deleted the pol-status branch January 29, 2021 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants