Skip to content

Commit ff8442b

Browse files
committed
fix(fingerprint): detect OKE service from raw OCID providerID
OKE nodes set spec.providerID to a bare OCID ("ocid1.instance.oc1...") with no scheme prefix, so the existing "oci://" split never matched and the raw OCID leaked into the service fingerprint. Fix in two layers: - pkg/collector/k8s: parseProvider checks strings.HasPrefix("ocid1.") before the "://" split; removes the unreachable "oci" case. - pkg/fingerprint: normalizeProviderID applied at read time so snapshots produced by older agent images are also corrected. Signed-off-by: Atif Mahmood <amahmood@nvidia.com> Signed-off-by: Atif Mahmood <atif1996@users.noreply.github.com>
1 parent ee608da commit ff8442b

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

pkg/collector/k8s/node.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (k *Collector) collectNode(ctx context.Context) (map[string]measurement.Rea
9292
// - aws:///us-west-2a/i-0123456789abcdef0 → "eks"
9393
// - gce://my-project/us-central1-a/gke-cluster-node → "gke"
9494
// - azure:///subscriptions/.../virtualMachines/... → "aks"
95-
// - oci://... → "oke"
95+
// - ocid1.instance.oc1... → "oke" (OKE emits a raw OCID, no scheme prefix)
9696
//
9797
// If the format is unrecognized, it returns the raw provider prefix.
9898
func parseProvider(providerID string) string {
@@ -101,6 +101,11 @@ func parseProvider(providerID string) string {
101101
return ""
102102
}
103103

104+
// OKE nodes set providerID to a raw Oracle OCID (no "://" scheme).
105+
if strings.HasPrefix(providerID, "ocid1.") {
106+
return "oke"
107+
}
108+
104109
// Split by "://" to get the provider prefix
105110
parts := strings.SplitN(providerID, "://", 2)
106111

@@ -114,8 +119,6 @@ func parseProvider(providerID string) string {
114119
return "gke"
115120
case "azure":
116121
return "aks"
117-
case "oci":
118-
return "oke"
119122
default:
120123
return provider
121124
}

pkg/collector/k8s/node_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,13 @@ func TestParseProvider(t *testing.T) {
209209
want: "aks",
210210
},
211211
{
212-
name: "OCI OKE",
213-
providerID: "oci://ocid1.instance.oc1.phx.abcdef123456",
212+
name: "OKE raw OCID (actual format)",
213+
providerID: "ocid1.instance.oc1.us-chicago-1.anxxeljsaqwjupqcb4pa5kzxy4hef5dtclbkqsnmu6kedbkrne3s2bz5nwzq",
214+
want: "oke",
215+
},
216+
{
217+
name: "OKE raw OCID short",
218+
providerID: "ocid1.instance.oc1.phx.abcdef123456",
214219
want: "oke",
215220
},
216221
{

pkg/fingerprint/from_measurements.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func populateFromK8s(fp *Fingerprint, m *measurement.Measurement) {
223223
}
224224
if st := m.GetSubtype(subtypeK8sNode); st != nil {
225225
if v, err := st.GetString(keyK8sNodeProvider); err == nil && v != "" {
226-
fp.Service = Dimension{Value: v, Source: sourceServiceProvider}
226+
fp.Service = Dimension{Value: normalizeProviderID(v), Source: sourceServiceProvider}
227227
}
228228
}
229229
}
@@ -320,6 +320,18 @@ func extractRegion(m *measurement.Measurement) (region string, multi bool) {
320320
return value, false
321321
}
322322

323+
// normalizeProviderID maps a raw Kubernetes spec.providerID (or an already-
324+
// normalized name stored by the collector) to the service type string used in
325+
// recipe criteria. OKE nodes emit a bare OCID ("ocid1.instance.oc1...") with
326+
// no scheme prefix; other providers use "<scheme>://..." which the collector
327+
// already normalizes, but we handle both here for resilience.
328+
func normalizeProviderID(v string) string {
329+
if strings.HasPrefix(v, "ocid1.") {
330+
return "oke"
331+
}
332+
return v
333+
}
334+
323335
// normalizeOSID maps an /etc/os-release ID value to the
324336
// recipe.CriteriaOSType enum. Returns "" for IDs that do not match a
325337
// supported OS kind so callers treat them as "fingerprint did not

0 commit comments

Comments
 (0)