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

fix!: remove list and watch on secrets. Fixes #8534 #8555

Merged
merged 23 commits into from May 13, 2022

Conversation

basanthjenuhb
Copy link
Contributor

@basanthjenuhb basanthjenuhb commented Apr 30, 2022

Signed-off-by: bjenuhb Basanth_JenuHB@intuit.com

Fixes #8534

bjenuhb added 2 commits April 30, 2022 21:21
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb basanthjenuhb changed the title fix: remove secrets fix: remove list and watch on secrets (fixes #8534) Apr 30, 2022
@basanthjenuhb basanthjenuhb changed the title fix: remove list and watch on secrets (fixes #8534) fix[DO NOT MERGE]: remove list and watch on secrets (fixes #8534) Apr 30, 2022
}
informerFactory.Start(ctx.Done())
informerFactory.WaitForCacheSync(ctx.Done())
return cache
}

func (c *ResourceCache) GetSecret(namespace string, secretName string) (*v12.Secret, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reason to introduce this method is if we want to introduce caching in future, we can easily change its implementation and keep external contract same

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb basanthjenuhb changed the title fix[DO NOT MERGE]: remove list and watch on secrets (fixes #8534) fix: remove list and watch on secrets (fixes #8534) May 1, 2022
@alexec alexec changed the title fix: remove list and watch on secrets (fixes #8534) fix: remove list and watch on secrets. Fixes #8534 May 1, 2022
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

We added to avoid repeated API calls. Prior to this there was a rought 1-to-1 mapping between Argo Server API calls and Kubernetes API calls O(1). This is now O(2).

Please use a cache (e.g lru) so that this is mitigated.

@basanthjenuhb
Copy link
Contributor Author

The problem with a cache is cache invalidation,
But got to know one info,
If the secret for that service account is deleted,
a new secret with a different name is recreated
so, since the name would be different, cache would be automatically invalidated.
Will add an LRU cache with 20 mins of refresh time

bjenuhb added 4 commits May 2, 2022 17:56
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb basanthjenuhb changed the title fix: remove list and watch on secrets. Fixes #8534 fix[DO NOT MERGE]: remove list and watch on secrets. Fixes #8534 May 2, 2022
@alexec
Copy link
Contributor

alexec commented May 2, 2022

It can be less than 20m. We only want to avoid doing 1 per call. A cache of 1m would work.

@alexec alexec marked this pull request as draft May 2, 2022 15:03
@basanthjenuhb
Copy link
Contributor Author

Just wanted to keep the timeout same as the informer
Since now cache invalidation is not an issue. 20m seems fine

Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

There was one bug that is not addressed in this PR: getResourceCacheNamespace() needs to consider --namespaced as well as --managed-namespace.

As you can see, the code only considers --namespaced option:

func getResourceCacheNamespace(opts ArgoServerOpts) string {
	if opts.Namespaced {
		return opts.SSONameSpace
	}
	return v1.NamespaceAll
}

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb
Copy link
Contributor Author

basanthjenuhb commented May 3, 2022

There was one bug that is not addressed in this PR: getResourceCacheNamespace() needs to consider --namespaced as well as --managed-namespace.

As you can see, the code only considers --namespaced option:

func getResourceCacheNamespace(opts ArgoServerOpts) string {
	if opts.Namespaced {
		return opts.SSONameSpace
	}
	return v1.NamespaceAll
}

Actually that piece of code is handled here
You can specify --sso-namespace. To determine which namespace to lookup service accounts from
https://github.com/argoproj/argo-workflows/blob/master/cmd/argo/commands/server.go#L146-L155

if namespaced {
    // Case 1: If ssoNamespace is not specified, default it to installation namespace
    if ssoNamespace == "" {
        ssoNamespace = namespace
    }
    // Case 2: If ssoNamespace is not equal to installation or managed namespace, default it to installation namespace
    if ssoNamespace != namespace && ssoNamespace != managedNamespace {
        log.Warn("--sso-namespace should be equal to --managed-namespace or the installation namespace")
        ssoNamespace = namespace
    }
}

It can either be instalation namespace or managed namespace

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb basanthjenuhb marked this pull request as ready for review May 3, 2022 07:08
bjenuhb added 3 commits May 3, 2022 12:49
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@basanthjenuhb basanthjenuhb changed the title fix[DO NOT MERGE]: remove list and watch on secrets. Fixes #8534 fix: remove list and watch on secrets. Fixes #8534 May 3, 2022
@basanthjenuhb
Copy link
Contributor Author

@alexec I feel 20 min should be fine since we don't have cache invalidation issue.
Let me know if you want it to be 1 min.

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
bjenuhb added 2 commits May 6, 2022 08:42
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
@alexec alexec enabled auto-merge (squash) May 6, 2022 04:38
@basanthjenuhb
Copy link
Contributor Author

@jessesuen
Can you have another look at the PR
I think the change regarding --managed-namespac and --namespaced could be done in a separate PR and needs discussion.

@basanthjenuhb
Copy link
Contributor Author

@jessesuen Anything else needed in this PR. want to take the PR to closure

@alexec alexec merged commit aa366db into argoproj:master May 13, 2022
This was referenced Jun 20, 2022
@sarabala1979 sarabala1979 mentioned this pull request Jul 30, 2022
51 tasks
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this pull request Sep 5, 2022
…8555)

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this pull request Sep 5, 2022
…8555)

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this pull request Sep 6, 2022
…8555)

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
terrytangyuan pushed a commit to akuity/argo-workflows that referenced this pull request Sep 7, 2022
…8555)

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
terrytangyuan pushed a commit to akuity/argo-workflows that referenced this pull request Sep 8, 2022
…8555)

Signed-off-by: bjenuhb <Basanth_JenuHB@intuit.com>
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

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

There appear to have been some undocumented breaking changes in this PR 😕

Those changes were unrelated to the goals and title of this PR too, which themselves were fully backward-compatible (as they only reduced permissions) 😕

@@ -224,7 +213,6 @@ See %s`, help.ArgoServer),
command.Flags().StringVar(&configMap, "configmap", common.ConfigMapName, "Name of K8s configmap to retrieve workflow controller configuration")
command.Flags().BoolVar(&namespaced, "namespaced", false, "run as namespaced mode")
command.Flags().StringVar(&managedNamespace, "managed-namespace", "", "namespace that watches, default to the installation namespace")
command.Flags().StringVar(&ssoNamespace, "sso-namespace", "", "namespace that will be used for SSO RBAC. Defaults to installation namespace. Used only in namespaced mode")
Copy link
Member

@agilgur5 agilgur5 Apr 25, 2024

Choose a reason for hiding this comment

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

This is a breaking change. I see it was discussed above, but it wasn't mentioned in the changelog or release notes (nor even the PR description). The PR title is also missing an exclamation point indicating breakage 😕 (I added the exclamation point myself post-hoc just now)

Comment on lines +100 to +103
ssoNamespace := namespace
if managedNamespace != "" {
ssoNamespace = managedNamespace
}
Copy link
Member

@agilgur5 agilgur5 Apr 25, 2024

Choose a reason for hiding this comment

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

this actually is different from the logic on line 151 and line 160 below. Those set the SSO namespace to the installation namespace when using a managed namespace. That makes sense, since your Argo configuration and Argo Server are in the installation namespace. Only your Workflows are in the managed namespace.

This change is actually quite confusing as a result, as due to this, with a managed namespace you now configure SSO RBAC there and not in the installation namespace. Normally that only happens when you enable SSO namespace delegation, which is named fairly explicitly.

This resulted in an undocumented breaking change that caused a regression too: #9989 (comment) 😕

@agilgur5 agilgur5 changed the title fix: remove list and watch on secrets. Fixes #8534 fix!: remove list and watch on secrets. Fixes #8534 Apr 25, 2024
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.

Argo Server with SSO enabled should not require List on all Secrets
5 participants