-
Notifications
You must be signed in to change notification settings - Fork 33
PCP-6208: Enhance MaaS machine handling during commissioning phase & add ip check before compose #324
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
base: spectro-master
Are you sure you want to change the base?
PCP-6208: Enhance MaaS machine handling during commissioning phase & add ip check before compose #324
Changes from all commits
a638bac
3687554
3bde1f2
37e3ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,10 @@ import ( | |
|
|
||
| // Service manages the MaaS machine | ||
| var ( | ||
| ErrBrokenMachine = errors.New("broken machine encountered") | ||
| ErrVMComposing = errors.New("vm composing/commissioning") | ||
| reHostID = regexp.MustCompile(`host (\d+)`) | ||
| reMachineID = regexp.MustCompile(`machine[s]? ([a-z0-9]{4,6})`) | ||
| ErrBrokenMachine = errors.New("broken machine encountered") | ||
| ErrVMComposing = errors.New("vm composing/commissioning") | ||
| reHostID = regexp.MustCompile(`host (\d+)`) | ||
| reMachineID = regexp.MustCompile(`machine[s]? ([a-z0-9]{4,6})`) | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -497,6 +497,26 @@ func (s *Service) PrepareLXDVM(ctx context.Context) (*infrav1beta1.Machine, erro | |
| } | ||
| } | ||
|
|
||
| // Before composing: check if the static IP is already allocated in MAAS | ||
| if s.scope.IsControlPlane() { | ||
| if staticIPToCheck := s.scope.GetStaticIP(); staticIPToCheck != "" { | ||
| s.scope.Info("Checking static IP availability before VM compose", "ip", staticIPToCheck) | ||
| existingIP, ipErr := s.maasClient.IPAddresses().GetAll(ctx, staticIPToCheck) | ||
| if ipErr == nil { | ||
| if ifaces := existingIP.InterfaceSet(); len(ifaces) > 0 { | ||
| return nil, fmt.Errorf("static IP %s is already in use (allocated to %d interface(s)); cannot compose VM — will retry when IP is available", staticIPToCheck, len(ifaces)) | ||
| } | ||
| // IP exists with no interfaces — stale/floating allocation; release before compose | ||
| s.scope.Info("Static IP has stale allocation with no interfaces; releasing before compose", "ip", staticIPToCheck) | ||
| if releaseErr := s.maasClient.IPAddresses().Release(ctx, staticIPToCheck); releaseErr != nil { | ||
| return nil, fmt.Errorf("static IP %s has a stale allocation that could not be released before compose: %w", staticIPToCheck, releaseErr) | ||
| } | ||
| s.scope.Info("Released stale IP allocation, proceeding with compose", "ip", staticIPToCheck) | ||
| } | ||
| // ipErr != nil means IP not found in MAAS — available, proceed normally | ||
| } | ||
| } | ||
|
|
||
| // Create the VM on the selected host | ||
| m, err := selectedHost.Composer().Compose(ctx, params) | ||
| if err != nil { | ||
|
|
@@ -827,7 +847,6 @@ func (s *Service) setMachineStaticIP(systemID string, config *infrav1beta1.Stati | |
| // Special handling for Commissioning state: skip static IP configuration to avoid blocking commissioning | ||
| if machineState == "Commissioning" { | ||
| s.scope.Info("Machine is commissioning, skipping static IP configuration to avoid interfering with commissioning process. Will configure after commissioning completes", "systemID", systemID) | ||
| // Return error to requeue - static IP will be configured after commissioning completes | ||
| return fmt.Errorf("machine is commissioning, static IP configuration will be retried after commissioning completes") | ||
| } | ||
|
Comment on lines
847
to
851
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
any reason to go for beta2 naming instead of updating minor version?
Also, maas client go release looks wrong, its a public repo we can avoid PCP taging there.
v0.1.4-beta2: Merge pull request #44 from spectrocloud/PCP-6208There 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.
Got it. I'll add a new feature in maas-client-go and update the minor version