fix(scheduler): netinterface cache is not informed (#22994)

This commit is contained in:
Zexi Li
2025-07-30 15:35:40 +08:00
committed by GitHub
parent 9d67950805
commit 897b22aaa2
3 changed files with 34 additions and 4 deletions
@@ -0,0 +1,30 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Netinterfaces modulebase.ResourceManager
)
func init() {
Netinterfaces = modules.NewComputeManager("netinterface", "netinterfaces",
[]string{}, []string{})
modules.RegisterCompute(&Netinterfaces)
}
+1 -1
View File
@@ -268,7 +268,7 @@ func (s *ResourceStore[O]) Update(oldObj, newObj *jsonutils.JSONDict) {
newObj = s.removeIgnoreKeys(newObj)
isEq := oldObj.String() == newObj.String()
if id != "" && !isEq {
dbObj, err := s.modelMan.FetchById(id)
dbObj, err := s.getDBObject(s.modelMan, id, newObj)
if err == nil {
v := reflect.ValueOf(dbObj)
tmpObj := v.Elem().Interface()
@@ -54,7 +54,7 @@ func GetId(hostId, wireId, mac string, vlanId int) string {
func NewResourceStore() common.IResourceStore[models.SNetInterface] {
return common.NewJointResourceStore(
models.NetInterfaceManager,
compute.Networkinterfaces,
compute.Netinterfaces,
func(o models.SNetInterface) string {
return GetId(o.BaremetalId, o.WireId, o.Mac, o.VlanId)
},
@@ -67,14 +67,14 @@ func NewResourceStore() common.IResourceStore[models.SNetInterface] {
},
func(man db.IModelManager, id string, obj *jsonutils.JSONDict) (db.IModel, error) {
ids := strings.Split(id, "/")
if len(ids) != 3 {
if len(ids) < 3 {
return nil, errors.Errorf("Invalid id: %q", id)
}
q := man.Query()
hostId := ids[0]
wireId := ids[1]
mac := ids[2]
q = q.Equals("host_id", hostId).Equals("wire_id", wireId).Equals("mac", mac)
q = q.Equals("baremetal_id", hostId).Equals("wire_id", wireId).Equals("mac", mac)
objs, err := db.FetchIModelObjects(man, q)
errHint := fmt.Sprintf("hostId %q, wireId %q, mac %q", hostId, wireId, mac)
if err != nil {