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

e2e: Easier to manage namespaces #1707

Merged
merged 3 commits into from
Dec 12, 2024
Merged

Conversation

nirs
Copy link
Member

@nirs nirs commented Dec 9, 2024

Clarify the way we use namespaces, and add a "e2e-" prefix for test namespaces.

Context includes now:

  • ManagementNamespace()
  • AppNamespace()

When using temporary variables, use either hubNamespace or clusterNamespace.

The application namespace has a "e2e-" prefix now.

Example namespaces during test:

% kubectl get ns --context dr1 | grep e2e-
e2e-appset-deploy-cephfs-busybox      Active   16m
e2e-appset-deploy-rbd-busybox         Active   16m
e2e-disapp-deploy-rbd-busybox         Active   14s
e2e-subscr-deploy-cephfs-busybox      Active   16m
e2e-subscr-deploy-rbd-busybox         Active   16m

Fixes #1611

@nirs nirs changed the title E2e namespace e2e: Easier to manage namespaces Dec 9, 2024
@nirs nirs force-pushed the e2e-namespace branch 7 times, most recently from 0b407d4 to 48bed2e Compare December 10, 2024 12:40
@nirs nirs marked this pull request as ready for review December 10, 2024 14:11
func (a ApplicationSet) Deploy(ctx types.Context) error {
name := ctx.Name()
log := ctx.Logger()
namespace := util.ArgocdNamespace
hubNamespace := ctx.ManagementNamespace()
Copy link
Member

Choose a reason for hiding this comment

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

I like the names ManagementNamespace and ApplicationNamespace. I don't understand why we are calling it hubNamespace here or clusterNamespace for applicationNamespace below. Whether is the namespace is on the hub or cluster is dependent on the operation and it should be clear based on the operation. I would prefer the variable also to be called managementNamespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding hub/cluster makes it more clear for someone which new to ramen. I can change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced with management/app.

@@ -14,6 +14,9 @@ import (
"go.uber.org/zap"
)

// Make it eaisr to manage namespaces created by the tests.
const namespacePrefix = "e2e-"
Copy link
Member

Choose a reason for hiding this comment

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

s/eaisr/easier/g

s/namespacePrefix/e2eNamespacePrefix/g

Second one is optional but it makes it clear.

Copy link
Member Author

@nirs nirs Dec 11, 2024

Choose a reason for hiding this comment

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

Maybe appNamespacesPrefix? Since we prefix only the app namespace. e2e is clear since we are in the context of e2e/test package.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced with appNamespacePrefix

nirs added 3 commits December 12, 2024 00:31
We use test.Context.Namespace() and namespace temporary variables for
different namespaces which makes the code confusing and error prone.

We have 2 namespaces:
- management namespace: used for OCM and ramen resources, on the hub and
  depending on the deployer also on the managed clusters.
- application namespace: use for application resources, and depending on
  the deployer, also for the OCM and ramen resources.

In addition we typically managed resources on the hub (subscription,
applicationset), but sometimes on the managed clusters (discovered
apps).

Changes:

- Rename types.Context.Namespace() to types.Context.ManagementNamespace()
- Add types.Context.AppNamespace()
- When using a namespace, use the relevant context namespaces, and call
  temporary variables managementNamespace or appNamespace.

Signed-off-by: Nir Soffer <[email protected]>
Add the management or app namespace to the initial
deploy/undeploy/protect/unprotect/failover/relocate logs.

Example logs (showing only "Deploying" logs):

    2024-12-10T11:11:23.616+0200	INFO subscr-deploy-rbd-busybox
    deployers/subscription.go:38 Deploying subscription in namespace
    "e2e-subscr-deploy-rbd-busybox"

    2024-12-10T11:11:23.616+0200	INFO	appset-deploy-rbd-busybox
    deployers/applicationset.go:19	Deploying applicationset in namespace "argocd"

    2024-12-10T11:11:23.616+0200	INFO	appset-deploy-cephfs-busybox
    deployers/applicationset.go:19	Deploying applicationset in namespace "argocd"

    2024-12-10T11:11:23.616+0200	INFO	disapp-deploy-rbd-busybox
    deployers/discoveredapps.go:30	Deploying workload in namespace
    "e2e-disapp-deploy-rbd-busybox"

    2024-12-10T11:11:23.616+0200	INFO	subscr-deploy-cephfs-busybox
    deployers/subscription.go:38	Deploying subscription in namespace
    "e2e-subscr-deploy-cephfs-busybox"

Signed-off-by: Nir Soffer <[email protected]>
It it hard to manage the namespaces created for every test when they
don't have a common prefix. Add "e2e-" prefix so all of them sort
together when listing namespaces.

Example namespaces during test:

    % kubectl get ns --context hub | grep e2e-
    e2e-subscr-deploy-cephfs-busybox     Active   6m2s
    e2e-subscr-deploy-rbd-busybox        Active   6m2s

    % kubectl get ns --context dr1 | grep e2e-
    e2e-disapp-deploy-rbd-busybox         Active   4m49s
    e2e-subscr-deploy-cephfs-busybox      Active   4m14s
    e2e-subscr-deploy-rbd-busybox         Active   4m48s

    % kubectl get ns --context dr2 | grep e2e-
    e2e-disapp-deploy-rbd-busybox         Active   5m10s
    e2e-subscr-deploy-cephfs-busybox      Active   5m8s
    e2e-subscr-deploy-rbd-busybox         Active   4m35s

Fixes: RamenDR#1611
Signed-off-by: Nir Soffer <[email protected]>
@nirs
Copy link
Member Author

nirs commented Dec 11, 2024

@raghavendra-talur should be ready when e2e job completes.

@raghavendra-talur raghavendra-talur merged commit 4563fb3 into RamenDR:main Dec 12, 2024
22 of 23 checks passed
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.

e2e: Easy to locate e2e namespaces
2 participants