Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Update client go #398

Merged
merged 7 commits into from
Mar 21, 2020
Merged

Update client go #398

merged 7 commits into from
Mar 21, 2020

Conversation

kkmsft
Copy link
Contributor

@kkmsft kkmsft commented Sep 28, 2019

Reason for Change:

  • Update client-go to avoid thread leak.

  • Simple command to test listing and accept GOOS from env

  • Fix cache sync calls

  • Misc. logging changes

Issue Fixed:

Notes for Reviewers:
TODO

  • Fix the usage of exit channel
  • Run e2e to validate
  • Add e2e to validate backward compatibility with older 1.5 and 1.3-1.4

@kkmsft
Copy link
Contributor Author

kkmsft commented Sep 28, 2019

E2E test results. One of them failed and passed on rerun:

Summarizing 1 Failure:

[Fail] Kubernetes cluster using aad-pod-identity [It] should assign identity with init containers
/Users/kkmsft/projects/aad-pod-identity/go/src/github.com/Azure/aad-pod-identity/test/e2e/aadpodidentity_test.go:1216

Ran 17 of 19 Specs in 3898.244 seconds
FAIL! -- 16 Passed | 1 Failed | 0 Pending | 2 Skipped
--- FAIL: TestAADPodIdentity (3898.24s)
FAIL
FAIL github.com/Azure/aad-pod-identity/test/e2e 3898.289s
make: *** [e2e] Error 1

[1] should assign identity with init containers
...

Ran 1 of 19 Specs in 257.761 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 18 Skipped
PASS

@kkmsft kkmsft force-pushed the go-client branch 2 times, most recently from 159219c to ee325ac Compare February 1, 2020 02:14
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

Just few small nits, otherwise lgtm

Since we don't have e2e test for SP, maybe we should validate that scenario manually too before merging the PR? Also, PR needs rebase.

cmd/simple/main.go Outdated Show resolved Hide resolved
pkg/apis/aadpodidentity/v1/types.go Outdated Show resolved Hide resolved
@kkmsft kkmsft force-pushed the go-client branch 2 times, most recently from 54220a3 to 90e16f9 Compare February 13, 2020 21:45
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

Added few comments but otherwise looks great!

For the docs, should we update the docs and examples with new case after we cut the release? If we update the examples and docs with this PR, it will not work for users trying out 1.5 releases.

cmd/mic/main.go Outdated
@@ -72,7 +75,20 @@ func main() {
//Identities that should be never removed from Azure AD (used defined managed identities)
flag.StringVar(&immutableUserMSIs, "immutable-user-msis", "", "prevent deletion of these IDs from the underlying VM/VMSS")

// Config map for aad-pod-identity
flag.StringVar(&cmConfig.Name, "cmName", "aad-pod-identity-cm", "Configmap name")
Copy link
Member

Choose a reason for hiding this comment

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

can we change this to config-map-name instead of cmName

Copy link
Member

Choose a reason for hiding this comment

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

can we use aad-pod-identity-config instead of aad-pod-identity-cm?

cmd/mic/main.go Outdated
// Config map for aad-pod-identity
flag.StringVar(&cmConfig.Name, "cmName", "aad-pod-identity-cm", "Configmap name")
// Config map details for the type changes in the context of client-go upgrade.
flag.StringVar(&typeUpgradeConfig.CMTypeUpgradeKey, "typeUpgradeCMKey", "type-upgrade-status", "Configmap key for type upgrade status")
Copy link
Member

Choose a reason for hiding this comment

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

we should use hyphen separated name instead of camel case similar to the other flags we have in MIC

"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog"
//"context"
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we remove this?

azureIdentity: "demo-aad1"
selector: "demo"
Copy link
Member

Choose a reason for hiding this comment

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

nit: new line

Copy link
Member

Choose a reason for hiding this comment

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

ditto as above

pkg/mic/mic.go Outdated
@@ -18,6 +18,7 @@ import (
"github.com/Azure/aad-pod-identity/version"
"golang.org/x/sync/semaphore"
corev1 "k8s.io/api/core/v1"
kubeErrors "k8s.io/apimachinery/pkg/api/errors"
Copy link
Member

Choose a reason for hiding this comment

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

can we rename this to apierrors instead of kubeErrors?

pkg/mic/mic.go Outdated
// Start ...
func (c *Client) Start(exit <-chan struct{}) {
klog.V(6).Infof("MIC client starting..")

if err := c.UpgradeTypeIfRequired(); err != nil {
klog.Fatalf("Upgrade failed with error: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should say type upgrade failed with error. I think we need to make this error message descriptive so the user what upgrade failed here


// There is a delay in data propogation to cache. It's possible that the creates performed in the previous sync cycle
// are not propogated before this sync cycle began. In order to avoid redoing the cycle, we sync cache again.
c.CRDClient.SyncCacheAll(exit, false)
Copy link
Member

Choose a reason for hiding this comment

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

Were you able to confirm that this cache sync with the go client update has no leaks?

pkg/mic/mic.go Outdated
@@ -417,19 +522,22 @@ func (c *Client) createDesiredAssignedIdentityList(
newAssignedIDs := make(map[string]aadpodid.AzureAssignedIdentity)

for _, pod := range listPods {
klog.V(6).Infof("checking pod: %s", pod.Name)
Copy link
Member

Choose a reason for hiding this comment

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

can we also add the pod namespace here to the log?

pkg/mic/mic.go Outdated
if pod.Spec.NodeName == "" {
//Node is not yet allocated. In that case skip the pod
klog.V(2).Infof("Pod %s/%s has no assigned node yet. it will be ignored", pod.Namespace, pod.Name)
continue
}
crdPodLabelVal := pod.Labels[aadpodid.CRDLabelKey]
klog.V(6).Infof("Label value: %v", crdPodLabelVal)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should also add the podns and podname in this log

pkg/mic/mic.go Outdated
if crdPodLabelVal == "" {
//No binding mentioned in the label. Just continue to the next pod
klog.V(2).Infof("Pod %s/%s has correct %s label but with no value. it will be ignored", pod.Namespace, pod.Name, aadpodid.CRDLabelKey)
continue
}
var matchedBindings []aadpodid.AzureIdentityBinding
for _, allBinding := range *listBindings {
klog.V(6).Infof("Check the binding: %s", allBinding.Spec.Selector)
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -4,5 +4,5 @@ metadata:
name: demo-aad1
spec:
type: 0
ResourceID: RESOURCE_ID
ClientID: CLIENT_ID
resourceID: RESOURCE_ID
Copy link
Member

@aramase aramase Mar 20, 2020

Choose a reason for hiding this comment

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

We should update these manifests right before we cut the new release as this will not work with current release.

Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

lgtm

@kkmsft looks like there are merge conflicts.

@kkmsft kkmsft merged commit 96e329b into Azure:master Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants