-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Davanum Srinivas <[email protected]>
- Loading branch information
Showing
14 changed files
with
113 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2025 Google Inc. All Rights Reserved. | ||
// | ||
// 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 resctrl | ||
|
||
import ( | ||
"fmt" | ||
"sync" | ||
"time" | ||
|
||
"github.com/google/cadvisor/stats" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
type ResControlManager interface { | ||
Destroy() | ||
GetCollector(containerName string, getContainerPids func() ([]string, error), numberOfNUMANodes int) (stats.Collector, error) | ||
} | ||
|
||
// All registered auth provider plugins. | ||
var pluginsLock sync.Mutex | ||
var plugins = make(map[string]ResControlManagerPlugin) | ||
|
||
type ResControlManagerPlugin interface { | ||
NewManager(interval time.Duration, vendorID string, inHostNamespace bool) (ResControlManager, error) | ||
} | ||
|
||
func RegisterPlugin(name string, plugin ResControlManagerPlugin) error { | ||
pluginsLock.Lock() | ||
defer pluginsLock.Unlock() | ||
if _, found := plugins[name]; found { | ||
return fmt.Errorf("ResControlManagerPlugin %q was registered twice", name) | ||
} | ||
klog.V(4).Infof("Registered ResControlManagerPlugin %q", name) | ||
plugins[name] = plugin | ||
return nil | ||
} | ||
|
||
func NewManager(interval time.Duration, vendorID string, inHostNamespace bool) (ResControlManager, error) { | ||
pluginsLock.Lock() | ||
defer pluginsLock.Unlock() | ||
for _, plugin := range plugins { | ||
return plugin.NewManager(interval, vendorID, inHostNamespace) | ||
} | ||
return nil, fmt.Errorf("unable to find plugins for resctrl manager") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
// limitations under the License. | ||
|
||
// Collector tests. | ||
package resctrl | ||
package intel | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2025 Google Inc. All Rights Reserved. | ||
// | ||
// 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 install | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/cadvisor/resctrl" | ||
"github.com/google/cadvisor/resctrl/intel" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
type managerplugin struct { | ||
} | ||
|
||
func (m *managerplugin) NewManager(interval time.Duration, vendorID string, inHostNamespace bool) (resctrl.ResControlManager, error) { | ||
return intel.NewManager(interval, intel.Setup, vendorID, inHostNamespace) | ||
} | ||
|
||
func init() { | ||
err := resctrl.RegisterPlugin("intel", &managerplugin{}) | ||
if err != nil { | ||
klog.Fatalf("Failed to register intel resctrl plugin: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
// limitations under the License. | ||
|
||
// Utilities. | ||
package resctrl | ||
package intel | ||
|
||
import ( | ||
"bufio" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters