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

bug(delete team): Clear cached clients & namespaces when switching namespaces #2503

Merged
merged 3 commits into from Dec 18, 2018

Conversation

@markawm
Copy link
Member

markawm commented Dec 13, 2018

JXClient, KubeClient, and namespaces are all cached for efficiency, but after switching namespaces these values might
be wrong. Clear them all out when changing namespaces, which will force the various setup methods in CommonOptions
(e.g. JXClient()) to create new ones, and recalculate dev namespaces etc.

Submitter checklist

  • Change is code complete and matches issue description.
  • Change is covered by existing or new tests.

Description

Special notes for the reviewer(s)

Which issue this PR fixes

fixes #2451

@jenkins-x-bot jenkins-x-bot requested review from amuniz and pmuir Dec 13, 2018

@markawm

This comment has been minimized.

Copy link
Member

markawm commented Dec 13, 2018

@@ -195,4 +194,11 @@ func (o *DeleteTeamOptions) changeNamespace(ns string) {
if err != nil {
log.Warnf("Failed to set context to namespace %s: %s", ns, err)
}

//Reset all the cached clients & namespace values when switching so that they can be properly recalculated for
//the new namespace.

This comment has been minimized.

@ccojocar

ccojocar Dec 14, 2018

Member

I would move this in a helper method in common.go such that it can be reused.

This comment has been minimized.

@markawm

markawm Dec 17, 2018

Member

Yeah, I wondered the same after pushing it - moved into CommonOptions so that everyone can switch NS easily.

@markawm

This comment has been minimized.

Copy link
Member

markawm commented Dec 17, 2018

/retest

@ccojocar

This comment has been minimized.

Copy link
Member

ccojocar commented Dec 17, 2018

/test bdd

@jenkins-x-bot jenkins-x-bot removed the lgtm label Dec 17, 2018

@ccojocar

This comment has been minimized.

Copy link
Member

ccojocar commented Dec 17, 2018

/test bdd

@@ -850,6 +850,25 @@ func (o *CommonOptions) GetWebHookEndpoint() (string, error) {
return webHookUrl, nil
}

func (o *CommonOptions) ChangeNamespace(ns string) {

This comment has been minimized.

@houndci-bot

houndci-bot Dec 17, 2018

Collaborator

exported method CommonOptions.ChangeNamespace should have comment or be unexported

markawm added some commits Dec 13, 2018

bug(delete team): Clear cached clients & namespaces when switching na…
…mespaces.

JXClient, KubeClient, and namespaces are all cached for efficiency, but after switching namespaces these values might
be wrong. Clear them all out when changing namespaces, which will force the various setup methods in CommonOptions
(e.g. JXClient()) to create new ones, and recalculate dev namespaces etc.

@markawm markawm force-pushed the markawm:delete-team-fail branch from b75559c to 4aae735 Dec 17, 2018

@jstrachan

This comment has been minimized.

Copy link
Member

jstrachan commented Dec 18, 2018

/lgtm

@jenkins-x-bot

This comment has been minimized.

Copy link
Contributor

jenkins-x-bot commented Dec 18, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ccojocar, jstrachan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot jenkins-x-bot merged commit c4e0bdb into jenkins-x:master Dec 18, 2018

2 checks passed

serverless-jenkins succeeded
tide In merge pool.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment