Skip to content

Commit 8053e9c

Browse files
authored
Fix segfault in bundle summary command (#1937)
## Changes This PR introduces use of new `isNil` method. It allows to ensure we filter out all improperly defined resources in `bundle summary` command. This includes deleted resources or resources with incorrect configuration such as only defining key of the resource and nothing else. Fixes #1919, #1913 ## Tests Added regression unit test case
1 parent 6fc2093 commit 8053e9c

File tree

14 files changed

+86
-11
lines changed

14 files changed

+86
-11
lines changed

bundle/config/resources.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type ConfigResource interface {
4141

4242
// InitializeURL initializes the URL field of the resource.
4343
InitializeURL(baseURL url.URL)
44+
45+
// IsNil returns true if the resource is nil, for example, when it was removed from the bundle.
46+
IsNil() bool
4447
}
4548

4649
// ResourceGroup represents a group of resources of the same type.
@@ -57,6 +60,9 @@ func collectResourceMap[T ConfigResource](
5760
) ResourceGroup {
5861
resources := make(map[string]ConfigResource)
5962
for key, resource := range input {
63+
if resource.IsNil() {
64+
continue
65+
}
6066
resources[key] = resource
6167
}
6268
return ResourceGroup{

bundle/config/resources/clusters.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ func (s *Cluster) GetName() string {
5656
func (s *Cluster) GetURL() string {
5757
return s.URL
5858
}
59+
60+
func (s *Cluster) IsNil() bool {
61+
return s.ClusterSpec == nil
62+
}

bundle/config/resources/dashboard.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ func (r *Dashboard) GetName() string {
7979
func (r *Dashboard) GetURL() string {
8080
return r.URL
8181
}
82+
83+
func (r *Dashboard) IsNil() bool {
84+
return r.Dashboard == nil
85+
}

bundle/config/resources/job.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ func (j *Job) GetName() string {
6363
func (j *Job) GetURL() string {
6464
return j.URL
6565
}
66+
67+
func (j *Job) IsNil() bool {
68+
return j.JobSettings == nil
69+
}

bundle/config/resources/mlflow_experiment.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ func (s *MlflowExperiment) GetName() string {
5858
func (s *MlflowExperiment) GetURL() string {
5959
return s.URL
6060
}
61+
62+
func (s *MlflowExperiment) IsNil() bool {
63+
return s.Experiment == nil
64+
}

bundle/config/resources/mlflow_model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ func (s *MlflowModel) GetName() string {
5858
func (s *MlflowModel) GetURL() string {
5959
return s.URL
6060
}
61+
62+
func (s *MlflowModel) IsNil() bool {
63+
return s.Model == nil
64+
}

bundle/config/resources/model_serving_endpoint.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ func (s *ModelServingEndpoint) GetName() string {
6666
func (s *ModelServingEndpoint) GetURL() string {
6767
return s.URL
6868
}
69+
70+
func (s *ModelServingEndpoint) IsNil() bool {
71+
return s.CreateServingEndpoint == nil
72+
}

bundle/config/resources/pipeline.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ func (p *Pipeline) GetName() string {
5858
func (s *Pipeline) GetURL() string {
5959
return s.URL
6060
}
61+
62+
func (s *Pipeline) IsNil() bool {
63+
return s.PipelineSpec == nil
64+
}

bundle/config/resources/quality_monitor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ func (s *QualityMonitor) GetName() string {
6262
func (s *QualityMonitor) GetURL() string {
6363
return s.URL
6464
}
65+
66+
func (s *QualityMonitor) IsNil() bool {
67+
return s.CreateMonitor == nil
68+
}

bundle/config/resources/registered_model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ func (s *RegisteredModel) GetName() string {
6868
func (s *RegisteredModel) GetURL() string {
6969
return s.URL
7070
}
71+
72+
func (s *RegisteredModel) IsNil() bool {
73+
return s.CreateRegisteredModelRequest == nil
74+
}

0 commit comments

Comments
 (0)