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

Test(e2e): re-enable upgrade test from nightly image #990

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

randmonkey
Copy link
Contributor

@randmonkey randmonkey commented Jan 10, 2025

What this PR does / why we need it:
As nightly images can be pushed again, we re-enable the e2e tests to upgrade from nightly.
Which issue this PR fixes

Fixes #

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

@randmonkey randmonkey self-assigned this Jan 10, 2025
@randmonkey randmonkey requested a review from a team as a code owner January 10, 2025 08:39
@@ -205,8 +205,7 @@ func TestHelmUpgrade(t *testing.T) {
},
},
},
/**
// TODO(Jintao): This test is disabled. After a new nightly image is available which uses KIC 3.4.1, we can enable it.

{
name: "upgrade from nightly to current",
fromVersion: "nightly",
Copy link
Member

Choose a reason for hiding this comment

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

This will require some more changes as now nightlies are being pushed to a separate repository: https://hub.docker.com/r/kong/nightly-gateway-operator-oss/tags

(for EE that's https://hub.docker.com/r/kong/nightly-gateway-operator/tags)

So we'll need to:

  • not make the repo hardcoded and allow override in EE repo
  • allow overriding the repository in testcases in this test.

@randmonkey randmonkey force-pushed the chore/enable_upgrade_from_nightly_again branch from 98bd50a to 0b463cd Compare January 21, 2025 07:02
@randmonkey
Copy link
Contributor Author

I found such reconciler errors in diagnostics:

{
  "level": "error",
  "ts": "2025-01-21T07:23:15Z",
  "msg": "Reconciler error",
  "controller": "controlplane",
  "controllerGroup": "gateway-operator.konghq.com",
  "controllerKind": "ControlPlane",
  "ControlPlane": {
    "name": "gw-upgrade-nightly-to-current-fnvw2-tmszg",
    "namespace": "7d44ebc6-36f3-47e1-a552-f1199ebef89d"
  },
  "namespace": "7d44ebc6-36f3-47e1-a552-f1199ebef89d",
  "name": "gw-upgrade-nightly-to-current-fnvw2-tmszg",
  "reconcileID": "c56445c2-e368-42fb-9b84-4d7ef81bf466",
  "error": "clusterroles.rbac.authorization.k8s.io is forbidden: user \"system:serviceaccount:7d44ebc6-36f3-47e1-a552-f1199ebef89d:controller-manager\" (groups=[\"system:serviceaccounts\" \"system:serviceaccounts:7d44ebc6-36f3-47e1-a552-f1199ebef89d\" \"system:authenticated\"]) is attempting to grant RBAC permissions not currently held:\n{APIGroups:[\"gateway.networking.k8s.io\"], Resources:[\"backendtlspolicies\"], Verbs:[\"get\" \"list\" \"watch\"]}\n{APIGroups:[\"gateway.networking.k8s.io\"], Resources:[\"backendtlspolicies/status\"], Verbs:[\"patch\" \"update\"]}",
  "stacktrace": "sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.0/pkg/internal/controller/controller.go:332\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.0/pkg/internal/controller/controller.go:279\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.0/pkg/internal/controller/controller.go:240"
}

Looks like we need to update the helm chart to grant the permissions of KGO to create cluster roles required for KIC 3.4 to operate backendtlspolicies.

@pmalek
Copy link
Member

pmalek commented Jan 21, 2025

  "error": "clusterroles.rbac.authorization.k8s.io is forbidden: user \"system:serviceaccount:7d44ebc6-36f3-47e1-a552-f1199ebef89d:controller-manager\" (groups=[\"system:serviceaccounts\" \"system:serviceaccounts:7d44ebc6-36f3-47e1-a552-f1199ebef89d\" \"system:authenticated\"]) is attempting to grant RBAC permissions not currently held:\n{APIGroups:[\"gateway.networking.k8s.io\"], Resources:[\"backendtlspolicies\"], Verbs:[\"get\" \"list\" \"watch\"]}\n{APIGroups:[\"gateway.networking.k8s.io\"], Resources:[\"backendtlspolicies/status\"], Verbs:[\"patch\" \"update\"]}",

BackendTLSPolicy RBAC rules have already been added in Kong/charts#1191 so this should work. What might be necessary here is to add the effective version for the nightly given that these RBAC rules are conditional on the version of KIC's image: https://github.com/Kong/charts/blob/94c153ca77d087ee2bba94686574dce588f204a5/charts/kong/templates/_helpers.tpl#L1307

@randmonkey
Copy link
Contributor Author

"error": "clusterroles.rbac.authorization.k8s.io is forbidden: user "system:serviceaccount:7d44ebc6-36f3-47e1-a552-f1199ebef89d:controller-manager" (groups=["system:serviceaccounts" "system:serviceaccounts:7d44ebc6-36f3-47e1-a552-f1199ebef89d" "system:authenticated"]) is attempting to grant RBAC permissions not currently held:\n{APIGroups:["gateway.networking.k8s.io"], Resources:["backendtlspolicies"], Verbs:["get" "list" "watch"]}\n{APIGroups:["gateway.networking.k8s.io"], Resources:["backendtlspolicies/status"], Verbs:["patch" "update"]}",

BackendTLSPolicy RBAC rules have already been added in Kong/charts#1191 so this should work. What might be necessary here is to add the effective version for the nightly given that these RBAC rules are conditional on the version of KIC's image: https://github.com/Kong/charts/blob/94c153ca77d087ee2bba94686574dce588f204a5/charts/kong/templates/_helpers.tpl#L1307

The error logs shows that KGO does not have the permission to grant the permission of operating backendtlspolicies to the clusterrole used by KIC. So I think it is caused by missing the permission in KGO's RBAC resources. Kong/charts#1230 should fix it.

@randmonkey randmonkey force-pushed the chore/enable_upgrade_from_nightly_again branch from 0b463cd to d79b408 Compare January 22, 2025 10:21
@randmonkey randmonkey force-pushed the chore/enable_upgrade_from_nightly_again branch from d79b408 to 8084313 Compare January 23, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants