Skip to content

Commit

Permalink
Cleanup only available VCLs. Don't delete an already discarded VCL. (#30
Browse files Browse the repository at this point in the history
)

Signed-off-by: Tomash Sidei <[email protected]>
  • Loading branch information
tomashibm authored Mar 24, 2021
1 parent 308a57d commit 8a6bcae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/varnishcontroller/controller/controller_varnish.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (r *ReconcileVarnish) reconcileVarnish(ctx context.Context, vc *v1alpha1.Va

// cleanup unused VCLs. It cleans up only VCLs created by varnish controller (those that start with our prefix)
for _, vclConfig := range configsList {
if vclConfig.Status != varnishadm.VCLStatusActive && strings.HasPrefix(vclConfig.Name, VCLVersionPrefix) {
if vclConfig.Status == varnishadm.VCLStatusAvailable && strings.HasPrefix(vclConfig.Name, VCLVersionPrefix) {
err := r.varnish.Discard(vclConfig.Name)
if err != nil {
return errors.Wrapf(err, "Can't delete VCL config %q", vclConfig.Name)
Expand Down
2 changes: 2 additions & 0 deletions pkg/varnishcontroller/varnishadm/varnishadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
VCLStatusAvailable = "available"
//VCLStatusActive - VCL configuration is active now
VCLStatusActive = "active"
//VCLStatusDiscarded - VCL configuration is discarded but still in use by in-flight requests
VCLStatusDiscarded = "discarded"
//VCLTemperatureCold - vanish VCL "temperature"
VCLTemperatureCold = "cold"
//VCLTemperatureWarm for preloaded varnish's VCL
Expand Down

0 comments on commit 8a6bcae

Please sign in to comment.