Skip to content

Commit

Permalink
Use default VS and TS templates when CfgMap obj is deleted (#6780)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjngx authored Nov 13, 2024
1 parent b9039e3 commit 214d9f1
Show file tree
Hide file tree
Showing 5 changed files with 1,838 additions and 19 deletions.
4 changes: 4 additions & 0 deletions internal/configs/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,14 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has

if virtualServerTemplate, exists := cfgm.Data["virtualserver-template"]; exists {
cfgParams.VirtualServerTemplate = &virtualServerTemplate
} else {
cfgParams.VirtualServerTemplate = nil
}

if transportServerTemplate, exists := cfgm.Data["transportserver-template"]; exists {
cfgParams.TransportServerTemplate = &transportServerTemplate
} else {
cfgParams.TransportServerTemplate = nil
}

if mainStreamSnippets, exists := GetMapKeyAsStringSlice(cfgm.Data, "stream-snippets", cfgm, "\n"); exists {
Expand Down
11 changes: 10 additions & 1 deletion internal/configs/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ func (cnf *Configurator) UpdateConfig(cfgParams *ConfigParams, resources Extende
return allWarnings, fmt.Errorf("error when parsing the main template: %w", err)
}
} else {
// Reverse to default main template parsed at NIC startup.
// Reverse to default Main template parsed at NIC startup.
cnf.templateExecutor.UseOriginalMainTemplate()
}

Expand All @@ -1327,20 +1327,29 @@ func (cnf *Configurator) UpdateConfig(cfgParams *ConfigParams, resources Extende
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the ingress template: %w", err)
}
} else {
// Reverse to default Ingress template parsed at NIC startup.
cnf.templateExecutor.UseOriginalIngressTemplate()
}

if cfgParams.VirtualServerTemplate != nil {
err := cnf.templateExecutorV2.UpdateVirtualServerTemplate(cfgParams.VirtualServerTemplate)
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the VirtualServer template: %w", err)
}
} else {
// Reverse to default TransportServer template parsed at NIC startup.
cnf.templateExecutorV2.UseOriginalVStemplate()
}

if cfgParams.TransportServerTemplate != nil {
err := cnf.templateExecutorV2.UpdateTransportServerTemplate(cfgParams.TransportServerTemplate)
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the TransportServer template: %w", err)
}
} else {
// Reverse to default TransportServer template parsed at NIC startup.
cnf.templateExecutorV2.UseOriginalTStemplate()
}

mainCfg := GenerateNginxMainConfig(cnf.staticCfgParams, cfgParams)
Expand Down
Loading

0 comments on commit 214d9f1

Please sign in to comment.