Skip to content

Commit 231a01b

Browse files
author
Sunil Thaha
authored
Merge pull request #2322 from vprashar2929/chore-skip-exp-val
chore: add experimental config validation skip option
2 parents 0eef5fe + 20a8f3e commit 231a01b

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

.github/workflows/profiling.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ jobs:
4141
go-version-file: go.mod
4242
cache: false
4343

44+
# NOTE: Using a specific SHA of pprof as
45+
# the latest version of pprof requires Go 1.24 or later
4446
- name: Install pprof
45-
run: go install github.com/google/pprof@latest
47+
run: go install github.com/google/pprof@6e76a2b096b5fa52e4bb3f7f7a357bd6e6b3b7b1
4648

4749
- name: Run Docker Compose services
4850
shell: bash
@@ -130,8 +132,10 @@ jobs:
130132
go-version-file: go.mod
131133
cache: false
132134

135+
# NOTE: Using a specific SHA of pprof as
136+
# the latest version of pprof requires Go 1.24 or later
133137
- name: Install pprof
134-
run: go install github.com/google/pprof@latest
138+
run: go install github.com/google/pprof@6e76a2b096b5fa52e4bb3f7f7a357bd6e6b3b7b1
135139

136140
- name: Download profiling artifacts
137141
uses: actions/download-artifact@v5

config/config.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ func (m *MetricsLevelValue) IsCumulative() bool {
189189
type SkipValidation int
190190

191191
const (
192-
SkipHostValidation SkipValidation = 1
193-
SkipKubeValidation SkipValidation = 2
192+
SkipHostValidation SkipValidation = 1
193+
SkipExperimentalValidation SkipValidation = 2
194194
)
195195

196196
const (
@@ -702,7 +702,7 @@ func (c *Config) Validate(skips ...SkipValidation) error {
702702
}
703703
}
704704
// Experimental Platform validation
705-
if experimentalErrs := c.validateExperimentalConfig(); len(experimentalErrs) > 0 {
705+
if experimentalErrs := c.validateExperimentalConfig(validationSkipped); len(experimentalErrs) > 0 {
706706
errs = append(errs, experimentalErrs...)
707707
}
708708

@@ -714,19 +714,21 @@ func (c *Config) Validate(skips ...SkipValidation) error {
714714
}
715715

716716
// validateExperimentalConfig validates experimental configuration settings
717-
func (c *Config) validateExperimentalConfig() []string {
718-
if !c.experimentalFeatureEnabled() {
717+
func (c *Config) validateExperimentalConfig(validationSkipped map[SkipValidation]bool) []string {
718+
if !c.experimentalFeatureEnabled() || validationSkipped[SkipExperimentalValidation] {
719719
return nil
720720
}
721721

722722
var errs []string
723723

724-
if c.IsFeatureEnabled(ExperimentalRedfishFeature) {
725-
if c.Experimental.Platform.Redfish.ConfigFile == "" {
726-
errs = append(errs, fmt.Sprintf("%s not supplied but %s set to true", ExperimentalPlatformRedfishConfigFlag, ExperimentalPlatformRedfishEnabledFlag))
727-
} else {
728-
if err := canReadFile(c.Experimental.Platform.Redfish.ConfigFile); err != nil {
729-
errs = append(errs, fmt.Sprintf("unreadable Redfish config file: %s: %s", c.Experimental.Platform.Redfish.ConfigFile, err.Error()))
724+
{ // Validate experimental settings
725+
if c.IsFeatureEnabled(ExperimentalRedfishFeature) {
726+
if c.Experimental.Platform.Redfish.ConfigFile == "" {
727+
errs = append(errs, fmt.Sprintf("%s not supplied but %s set to true", ExperimentalPlatformRedfishConfigFlag, ExperimentalPlatformRedfishEnabledFlag))
728+
} else {
729+
if err := canReadFile(c.Experimental.Platform.Redfish.ConfigFile); err != nil {
730+
errs = append(errs, fmt.Sprintf("unreadable Redfish config file: %s: %s", c.Experimental.Platform.Redfish.ConfigFile, err.Error()))
731+
}
730732
}
731733
}
732734
}

config/config_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,21 @@ func TestValidateWithSkip(t *testing.T) {
590590
// Validate with skipping host validation
591591
err := cfg.Validate(SkipHostValidation)
592592
assert.NoError(t, err, "Should pass when SkipHostValidation is provided")
593+
594+
// Create a config with invalid experimental config
595+
cfg = DefaultConfig()
596+
cfg.Experimental = &Experimental{
597+
Platform: Platform{
598+
Redfish: Redfish{
599+
Enabled: ptr.To(true),
600+
ConfigFile: "/path/invalid",
601+
},
602+
},
603+
}
604+
605+
// Validate with skipping experimental validation
606+
err = cfg.Validate(SkipExperimentalValidation)
607+
assert.NoError(t, err, "Should pass when SkipExperimentalValidation is provided")
593608
}
594609

595610
func TestMonitorConfig(t *testing.T) {
@@ -2355,7 +2370,7 @@ func TestValidateExperimentalConfig(t *testing.T) {
23552370

23562371
for _, tc := range tests {
23572372
t.Run(tc.name, func(t *testing.T) {
2358-
errors := tc.config.validateExperimentalConfig()
2373+
errors := tc.config.validateExperimentalConfig(nil)
23592374

23602375
if tc.expectedErrors == nil {
23612376
assert.Empty(t, errors)

0 commit comments

Comments
 (0)