This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 255
NMI retries and ticker for periodic sync reconcile #272
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cbc9374
nmi retry and sync retry loop
aramase 51ed824
reduce retry count, update tests, check context
aramase 53865c8
remove dead code
aramase a89d143
pass sync duration
aramase c358db9
update retry logic based on states
aramase b64e15b
return map from list pod ids
aramase 99401bd
return diff error
aramase 62e3502
ensure backward compat
aramase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package main | |
import ( | ||
"flag" | ||
"os" | ||
"time" | ||
|
||
"github.com/Azure/aad-pod-identity/pkg/mic" | ||
"github.com/Azure/aad-pod-identity/version" | ||
|
@@ -12,10 +13,11 @@ import ( | |
) | ||
|
||
var ( | ||
kubeconfig string | ||
cloudconfig string | ||
forceNamespaced bool | ||
versionInfo bool | ||
kubeconfig string | ||
cloudconfig string | ||
forceNamespaced bool | ||
versionInfo bool | ||
syncRetryInterval string | ||
) | ||
|
||
func main() { | ||
|
@@ -24,6 +26,8 @@ func main() { | |
flag.StringVar(&cloudconfig, "cloudconfig", "", "Path to cloud config e.g. Azure.json file") | ||
flag.BoolVar(&forceNamespaced, "forceNamespaced", false, "Forces namespaced identities, binding, and assignment") | ||
flag.BoolVar(&versionInfo, "version", false, "Prints the version information") | ||
flag.StringVar(&syncRetryInterval, "syncRetryInterval", "3600s", "The interval in seconds at which sync loop should periodically check for errors and reconcile.") | ||
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. Change to duration var |
||
|
||
flag.Parse() | ||
if versionInfo { | ||
version.PrintVersionAndExit() | ||
|
@@ -43,7 +47,13 @@ func main() { | |
} | ||
|
||
forceNamespaced = forceNamespaced || "true" == os.Getenv("FORCENAMESPACED") | ||
micClient, err := mic.NewMICClient(cloudconfig, config, forceNamespaced) | ||
|
||
syncRetryDuration, err := time.ParseDuration(syncRetryInterval) | ||
if err != nil { | ||
glog.Fatalf("Could not read syncRetryInterval. Error %+v", err) | ||
} | ||
|
||
micClient, err := mic.NewMICClient(cloudconfig, config, forceNamespaced, syncRetryDuration) | ||
if err != nil { | ||
glog.Fatalf("Could not get the MIC client: %+v", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ type ClientInt interface { | |
ListBindings() (res *[]aadpodid.AzureIdentityBinding, err error) | ||
ListAssignedIDs() (res *[]aadpodid.AzureAssignedIdentity, err error) | ||
ListIds() (res *[]aadpodid.AzureIdentity, err error) | ||
ListPodIds(podns, podname string) (*[]aadpodid.AzureIdentity, error) | ||
ListPodIds(podns, podname string) (map[string][]aadpodid.AzureIdentity, error) | ||
} | ||
|
||
func NewCRDClientLite(config *rest.Config) (crdClient *Client, err error) { | ||
|
@@ -257,22 +257,22 @@ func (c *Client) ListIds() (res *[]aadpodid.AzureIdentity, err error) { | |
return &ret.(*aadpodid.AzureIdentityList).Items, nil | ||
} | ||
|
||
//ListPodIds - given a pod with pod name space | ||
func (c *Client) ListPodIds(podns, podname string) (*[]aadpodid.AzureIdentity, error) { | ||
// ListPodIds - given a pod with pod name space | ||
// returns a map with list of azure identities in each state | ||
func (c *Client) ListPodIds(podns, podname string) (map[string][]aadpodid.AzureIdentity, error) { | ||
azAssignedIDList, err := c.AssignedIDListWatch.List(v1.ListOptions{}) | ||
if err != nil { | ||
glog.Error(err) | ||
return nil, err | ||
} | ||
|
||
var matchedIds []aadpodid.AzureIdentity | ||
idStateMap := make(map[string][]aadpodid.AzureIdentity) | ||
for _, v := range azAssignedIDList.(*aadpodid.AzureAssignedIdentityList).Items { | ||
if v.Spec.Pod == podname && v.Spec.PodNamespace == podns { | ||
matchedIds = append(matchedIds, *v.Spec.AzureIdentityRef) | ||
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. Can we please add a comment in the next PR indicating the backward compatibility aspects. |
||
idStateMap[v.Status.Status] = append(idStateMap[v.Status.Status], *v.Spec.AzureIdentityRef) | ||
} | ||
} | ||
|
||
return &matchedIds, nil | ||
return idStateMap, nil | ||
} | ||
|
||
type patchStatusOps struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is the usage of count here ?
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.
It's to ensure the test runs at least once instead of showing the cached result.