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

print the related namespace when login via manager cluster #274

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

bmeng
Copy link
Contributor

@bmeng bmeng commented Dec 1, 2023

What type of PR is this?

(feature)

What this PR does / Why we need it?

It prints the cluster related namespaces when login with the --manager option, since user may like to investigate the resources within

Which Jira/Github issue(s) does this PR fix?

Resolves #OSD-19081

Special notes for your reviewer

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2023

Codecov Report

Merging #274 (005f458) into main (d01e44d) will decrease coverage by 0.23%.
Report is 4 commits behind head on main.
The diff coverage is 53.65%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #274      +/-   ##
==========================================
- Coverage   46.91%   46.68%   -0.23%     
==========================================
  Files          53       53              
  Lines        3568     3911     +343     
==========================================
+ Hits         1674     1826     +152     
- Misses       1633     1792     +159     
- Partials      261      293      +32     
Files Coverage Δ
pkg/cli/session/session.go 50.44% <0.00%> (ø)
cmd/ocm-backplane/login/login.go 68.52% <73.33%> (+2.25%) ⬆️
pkg/ocm/ocmWrapper.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

Comment on lines 144 to 154
var env string
if strings.Contains(bpURL, "integration") {
env = "integration"
} else if strings.Contains(bpURL, "stage") {
env = "staging"
} else {
env = "production"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This may expose all available RH env's to the public. You may able to get the env with ocm get /api/clusters_mgmt/v1/environment API or wait for OSD-19188 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I feel after the OSD-19188 there would be easier way to get it.
But I think even with the ocm get, the namespace prefix may not match the env name? like staging vs stage

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we shouldn't be exposing any clue what our API URLs even look like. I wouldn't prefer to let this change in.

Comment on lines 376 to 400
func listNamespaces(clusterID, clusterName, env string, isHypershift bool) []string {

klusterletPrefix := "klusterlet-"
hivePrefix := fmt.Sprintf("uhc-%s-", env)
hcpPrefix := fmt.Sprintf("ocm-%s-", env)

var nsList []string

if isHypershift {
nsList = []string{
klusterletPrefix + clusterID,
hcpPrefix + clusterID,
hcpPrefix + clusterID + "-" + clusterName,
}
} else {
nsList = []string{
hivePrefix + clusterID,
}
}

return nsList
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we get the matching namespaces via bp-api endpoint ? basically oc get ns -A| grep {cluster-internal-id}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just think to send less api request, if we do the oc get ns we even do not need to detect the env

Copy link
Contributor

Choose a reason for hiding this comment

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

The namespace pattern is fixed so it should be ok to print them directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this pattern unique to the FedRamp stack too?

pkg/utils/ocmWrapper.go Outdated Show resolved Hide resolved
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 5, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2023
@bmeng
Copy link
Contributor Author

bmeng commented Dec 6, 2023

/hold

Hold this for now, as we are waiting for an implementation which can get the env info automatically

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 6, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 14, 2023
@samanthajayasinghe
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 15, 2023
Copy link
Contributor

openshift-ci bot commented Dec 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bmeng, samanthajayasinghe

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:
  • OWNERS [bmeng,samanthajayasinghe]

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

@bmeng
Copy link
Contributor Author

bmeng commented Dec 15, 2023

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 15, 2023
Copy link
Contributor

openshift-ci bot commented Dec 15, 2023

@bmeng: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 4fd23c7 into openshift:main Dec 15, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants