-
Notifications
You must be signed in to change notification settings - Fork 7.5k
feat: Enhance ArgoCD CLI: Dynamic Repo Server Retrieval with --core and --refresh Flags #17613
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
Changes from 11 commits
87bc574
4987796
29b0e7a
3b060b4
5319368
f67255d
69713b1
ec4b22a
dde9a3e
eb41e7c
22e28e2
2610292
6049c22
4c30993
58a7e28
4b1ccee
fdba5b1
d051cab
39e5371
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import ( | |
| "github.com/redis/go-redis/v9" | ||
| log "github.com/sirupsen/logrus" | ||
| "github.com/spf13/pflag" | ||
| v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/util/runtime" | ||
| "k8s.io/client-go/kubernetes" | ||
| cache2 "k8s.io/client-go/tools/cache" | ||
|
|
@@ -115,14 +116,27 @@ type forwardRepoClientset struct { | |
| repoClientset repoapiclient.Clientset | ||
| err error | ||
| repoServerName string | ||
| kubeClientset kubernetes.Interface | ||
| } | ||
|
|
||
| func (c *forwardRepoClientset) NewRepoServerClient() (io.Closer, repoapiclient.RepoServerServiceClient, error) { | ||
| c.init.Do(func() { | ||
| overrides := clientcmd.ConfigOverrides{ | ||
| CurrentContext: c.context, | ||
| } | ||
| repoServerPodLabelSelector := common.LabelKeyAppName + "=" + c.repoServerName | ||
| repoServerName := c.repoServerName | ||
| repoServererviceLabelSelector := common.LabelKeyComponentRepoServer + "=" + common.LabelValueComponentRepoServer | ||
| repoServerServices, err := c.kubeClientset.CoreV1().Services(c.namespace).List(context.Background(), v1.ListOptions{LabelSelector: repoServererviceLabelSelector}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of deriving the argocd instance name from the services, can we not apply the label
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @anandf, I will update the implementation and add the labels "app.kubernetes.io/component=repo-server" to repo-server replica pods in the manifest
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switching to |
||
| if err != nil { | ||
| c.err = err | ||
| return | ||
| } | ||
| if len(repoServerServices.Items) > 0 { | ||
| if repoServerServicelabel, ok := repoServerServices.Items[0].Labels[common.LabelKeyAppName]; ok && repoServerServicelabel != "" { | ||
| repoServerName = repoServerServicelabel | ||
| } | ||
| } | ||
| repoServerPodLabelSelector := common.LabelKeyAppName + "=" + repoServerName | ||
| repoServerPort, err := kubeutil.PortForward(8081, c.namespace, &overrides, repoServerPodLabelSelector) | ||
| if err != nil { | ||
| c.err = err | ||
|
|
@@ -237,7 +251,7 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti | |
| KubeClientset: kubeClientset, | ||
| Insecure: true, | ||
| ListenHost: *address, | ||
| RepoClientset: &forwardRepoClientset{namespace: namespace, context: ctxStr, repoServerName: clientOpts.RepoServerName}, | ||
| RepoClientset: &forwardRepoClientset{namespace: namespace, context: ctxStr, repoServerName: clientOpts.RepoServerName, kubeClientset: kubeClientset}, | ||
| EnableProxyExtension: false, | ||
| }) | ||
| srv.Init(ctx) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,7 +437,7 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e | |
| return nil, fmt.Errorf("error getting cluster: %w", err) | ||
| } | ||
|
|
||
| if !c.canHandleCluster(cluster) { | ||
| if !c.canHandleCluster(cluster) && c.clusterSharding == nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the nil check should come first isn't it ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @anandf, I have updated the code to handle nil ptr dereference separately |
||
| return nil, fmt.Errorf("controller is configured to ignore cluster %s", cluster.Server) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
repoServerServiceLabelSelectorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ishitasequeira, Updating the same.