-
Notifications
You must be signed in to change notification settings - Fork 254
OCPBUGS-122165: Reduce vCenter API load in the vSphere machine controller #1552
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
Draft
jcpowermac
wants to merge
12
commits into
openshift:main
Choose a base branch
from
jcpowermac:ocpbugs-122165
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
21dec13
vsphere: raise controller cache resync from 10m to 30m
jcpowermac 263252a
vsphere: add --max-concurrent-reconciles (default 10)
jcpowermac 2fead27
vsphere: assert 30m sync period in main test
jcpowermac 21001ab
vsphere: clear finished task ref on update to skip GetTask
jcpowermac 8daa9d2
vsphere: skip region/zone tag walk when labels already set
jcpowermac 931729d
vsphere: dedup power-state/name/UUID fetches on steady-state resync
jcpowermac 5ae318a
vsphere: reset machine identity when re-cloning VM
jcpowermac 5e4bc6c
vsphere: guard TaskIDCache with a mutex
jcpowermac bb4e641
vsphere: clear terminal failed task ref in update
jcpowermac 2142c1a
vsphere: clear TaskRef only for terminal failed tasks
jcpowermac 8c2c11d
vsphere: address review findings from bot review
jcpowermac 61bbeea
vsphere: make --sync-period a flag (default 30m)
jcpowermac 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| func TestSyncPeriodDefault(t *testing.T) { | ||
| // The flag is registered in main(); register it in a test flagset | ||
| // by calling the helper that wires flags. | ||
| fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
| _, syncPeriod := registerControllerFlags(fs) | ||
| if *syncPeriod != 30*time.Minute { | ||
| t.Errorf("default sync-period = %s, want 30m", *syncPeriod) | ||
| } | ||
| } | ||
|
|
||
| func TestSyncPeriodCustom(t *testing.T) { | ||
| fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
| _, syncPeriod := registerControllerFlags(fs) | ||
| if err := fs.Parse([]string{"--sync-period=45m"}); err != nil { | ||
| t.Fatalf("unexpected error parsing flags: %v", err) | ||
| } | ||
| if *syncPeriod != 45*time.Minute { | ||
| t.Errorf("expected sync-period = 45m, got %s", *syncPeriod) | ||
| } | ||
| } | ||
|
|
||
| func TestValidateSyncPeriod(t *testing.T) { | ||
| for _, tc := range []struct { | ||
| name string | ||
| val time.Duration | ||
| wantErr bool | ||
| }{ | ||
| {name: "default", val: 30 * time.Minute}, | ||
| {name: "min", val: time.Minute}, | ||
| {name: "max", val: time.Hour}, | ||
| {name: "below min", val: 30 * time.Second, wantErr: true}, | ||
| {name: "over max", val: 2 * time.Hour, wantErr: true}, | ||
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| err := validateSyncPeriod(tc.val) | ||
| if (err != nil) != tc.wantErr { | ||
| t.Errorf("validateSyncPeriod(%s) err = %v, wantErr %v", tc.val, err, tc.wantErr) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestMaxConcurrentReconcilesDefault(t *testing.T) { | ||
| fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
| maxConcurrent, _ := registerControllerFlags(fs) | ||
| if *maxConcurrent != 10 { | ||
| t.Errorf("default max-concurrent-reconciles = %d, want 10", *maxConcurrent) | ||
| } | ||
| } | ||
|
|
||
| func TestMaxConcurrentReconcilesCustom(t *testing.T) { | ||
| fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
| maxConcurrent, _ := registerControllerFlags(fs) | ||
| if err := fs.Parse([]string{"--max-concurrent-reconciles=5"}); err != nil { | ||
| t.Fatalf("unexpected error parsing flags: %v", err) | ||
| } | ||
| if *maxConcurrent != 5 { | ||
| t.Errorf("expected max-concurrent-reconciles = 5, got %d", *maxConcurrent) | ||
| } | ||
| } | ||
|
|
||
| func TestValidateMaxConcurrentReconciles(t *testing.T) { | ||
| for _, tc := range []struct { | ||
| name string | ||
| val int | ||
| wantErr bool | ||
| }{ | ||
| {name: "default", val: 10}, | ||
| {name: "min", val: 1}, | ||
| {name: "max", val: 100}, | ||
| {name: "zero", val: 0, wantErr: true}, | ||
| {name: "negative", val: -1, wantErr: true}, | ||
| {name: "over limit", val: 101, wantErr: true}, | ||
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| err := validateMaxConcurrentReconciles(tc.val) | ||
| if (err != nil) != tc.wantErr { | ||
| t.Errorf("validateMaxConcurrentReconciles(%d) err = %v, wantErr %v", tc.val, err, tc.wantErr) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.