kubernetes/kops · warning

flag %s not found

Error message

flag %s not found

What it means

featureflag.Get looks up a registered FeatureFlag by name in the global flags map and returns this error when no flag with that name has been registered. Feature flags must first be created (e.g. via featureflag.CreateFlag or a spec-based registration) before Get can retrieve them. Note that ParseFlags logs unknown flags instead of failing, so this error surfaces mainly from direct Get calls.

Source

Thrown at pkg/featureflag/featureflag.go:203

			parsed++
		} else {
			klog.Infof("Unknown FeatureFlag %q", s)
			unknown++
		}
	}
	if f != "" {
		klog.Infof("ParseFlags: parsed %d flags from %q (unknown=%d, registered=%d)", parsed, f, unknown, len(flags))
	}
}

// Get returns given FeatureFlag.
func Get(flagName string) (*FeatureFlag, error) {
	flagsMutex.Lock()
	defer flagsMutex.Unlock()

	flag, found := flags[flagName]
	if !found {
		return nil, fmt.Errorf("flag %s not found", flagName)
	}
	return flag, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the exact flag name against the registered flags (grep for CreateFlag/spec registrations in pkg/featureflag) — the lookup is case-sensitive and exact.
  2. Register the flag before calling Get, e.g. featureflag.CreateFlag("MyFlag", true) in an init() or setup path that is guaranteed to run.
  3. If setting via the KOPS_FEATURE_FLAGS environment variable, correct any misspelled names; unknown names are only logged at parse time but Get will fail.
  4. If migrating across kops versions, verify the flag still exists or use its replacement.

Example fix

// before: calling Get for an unregistered/misspelled flag
ff, err := featureflag.Get("EnableSeparateEtcd")
// after: register first, then Get (or check registration)
featureflag.CreateFlag("EnableSeparateEtcd", false)
ff, err := featureflag.Get("EnableSeparateEtcd")
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the flag is registered before Get
featureflag.CreateFlag("MyFlag", true) // idempotent registration in init()/setup
ff, err := featureflag.Get("MyFlag")

Try / catch

// treat lookup failure as "flag unavailable", fall back to default
ff, err := featureflag.Get("MyFlag")
if err != nil {
    klog.V(2).Infof("feature flag MyFlag not registered, using default: %v", err)
    enabled = false
} else {
    enabled = ff.Enabled()
}

Prevention

When it happens

Trigger: Calling featureflag.Get("SomeFlag") when the flag was never registered via CreateFlag/New in the process; a typo in the flag name (lookup is by exact string); calling Get before the package or command that registers the flag has run its init(); using a flag that was renamed or removed in a kops version change.

Common situations: Custom tooling importing kops' featureflag package and querying a kops-internal flag that isn't registered in that binary; tests enabling flags via the KOPS_FEATURE_FLAGS env var where the name is misspelled (ParseFlags logs "Unknown FeatureFlag" and Get then fails); upgrading kops and referencing a flag that no longer exists.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/63f835f29253354b. Report an issue: GitHub.