Skip to content

Commit 706232c

Browse files
committed
Log catalogd feature gate states
1 parent 02fa296 commit 706232c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cmd/catalogd/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ func validateConfig(cfg *config) error {
188188
}
189189

190190
func run(ctx context.Context) error {
191+
// log startup message and feature gate status
192+
setupLog.Info("starting up catalogd", "version info", version.String())
193+
features.LogFeatureGateStates(setupLog, features.CatalogdFeatureGate)
191194
authFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s.json", authFilePrefix, apimachineryrand.String(8)))
192195

193196
protocol := "http://"

internal/catalogd/features/features.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package features
22

33
import (
4+
"sort"
5+
6+
"github.com/go-logr/logr"
47
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
58
"k8s.io/component-base/featuregate"
69
)
@@ -18,3 +21,21 @@ var CatalogdFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureG
1821
func init() {
1922
utilruntime.Must(CatalogdFeatureGate.Add(catalogdFeatureGates))
2023
}
24+
25+
// LogFeatureGateStates logs the state of all known feature gates for catalogd
26+
func LogFeatureGateStates(log logr.Logger, fg featuregate.FeatureGate) {
27+
// Sort the keys for consistent logging order
28+
featureKeys := make([]featuregate.Feature, 0, len(catalogdFeatureGates))
29+
for k := range catalogdFeatureGates {
30+
featureKeys = append(featureKeys, k)
31+
}
32+
sort.Slice(featureKeys, func(i, j int) bool {
33+
return string(featureKeys[i]) < string(featureKeys[j])
34+
})
35+
36+
featurePairs := make([]interface{}, 0, len(featureKeys))
37+
for _, feature := range featureKeys {
38+
featurePairs = append(featurePairs, feature, fg.Enabled(feature))
39+
}
40+
log.Info("catalogd feature gate status", featurePairs...)
41+
}

0 commit comments

Comments
 (0)