Skip to content

Commit d830271

Browse files
author
Mickaël Le Baillif
committed
Add safety checks for nil configurations in updateComputeConfig
1 parent b95fa10 commit d830271

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/resource/cluster/hook.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,20 @@ func (rm *resourceManager) updateComputeConfig(
742742
exit := rlog.Trace("rm.updateComputeConfig")
743743
defer exit(err)
744744

745+
// Safety check: ensure ComputeConfig is not nil
746+
if r == nil || r.ko == nil || r.ko.Spec.ComputeConfig == nil {
747+
rlog.Debug("skipping updateComputeConfig: ComputeConfig is nil")
748+
return nil
749+
}
750+
751+
// Safety check: ensure all required configurations are not nil
752+
if r.ko.Spec.StorageConfig == nil || r.ko.Spec.StorageConfig.BlockStorage == nil {
753+
return fmt.Errorf("invalid Auto Mode configuration: StorageConfig.BlockStorage is required")
754+
}
755+
if r.ko.Spec.KubernetesNetworkConfig == nil || r.ko.Spec.KubernetesNetworkConfig.ElasticLoadBalancing == nil {
756+
return fmt.Errorf("invalid Auto Mode configuration: KubernetesNetworkConfig.ElasticLoadBalancing is required")
757+
}
758+
745759
// Convert []*string to []string for NodePools
746760
nodePools := make([]string, 0, len(r.ko.Spec.ComputeConfig.NodePools))
747761
for _, nodePool := range r.ko.Spec.ComputeConfig.NodePools {

0 commit comments

Comments
 (0)