Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions pkg/object/meshcontroller/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,21 @@ func (m *Master) checkServiceInstances() {
statuses := m.service.ListAllServiceInstanceStatuses()
specs := m.service.ListAllServiceInstanceSpecs()

type instanceKey struct {
serviceName string
instanceID string
}
statusMap := make(map[instanceKey]*spec.ServiceInstanceStatus, len(statuses))
for _, s := range statuses {
statusMap[instanceKey{s.ServiceName, s.InstanceID}] = s
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composite key literals rely on positional field order, which is easy to accidentally swap later. Prefer keyed struct literals for clarity and safety (e.g., instanceKey{serviceName: ..., instanceID: ...}).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

}

for _, _spec := range specs {
if !m.isMeshRegistryName(_spec.RegistryName) {
continue
}

// TODO: improve search performance
var status *spec.ServiceInstanceStatus
for _, s := range statuses {
if s.ServiceName == _spec.ServiceName && s.InstanceID == _spec.InstanceID {
status = s
}
}
status := statusMap[instanceKey{_spec.ServiceName, _spec.InstanceID}]
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composite key literals rely on positional field order, which is easy to accidentally swap later. Prefer keyed struct literals for clarity and safety (e.g., instanceKey{serviceName: ..., instanceID: ...}).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


if status == nil {
format := "status of %s/%s not found, need to delete"
Expand Down
Loading