Skip to content

Commit

Permalink
adding observed generation and not wiping CT VAPgeneration status
Browse files Browse the repository at this point in the history
Signed-off-by: Jaydip Gabani <[email protected]>
  • Loading branch information
JaydipGabani committed Nov 16, 2024
1 parent d67ef29 commit ae48233
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions apis/status/v1beta1/constrainttemplatepodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ type ConstraintTemplatePodStatusStatus struct {
Operations []string `json:"operations,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Errors []*templatesv1beta1.CreateCRDError `json:"errors,omitempty"`
VAPGenerationStatus VAPGenerationStatus `json:"vapGenerationStatus,omitempty"`
VAPGenerationStatus *VAPGenerationStatus `json:"vapGenerationStatus,omitempty"`
}

// VAPGenerationStatus represents the status of VAP generation.
type VAPGenerationStatus struct {
State string `json:"state,omitempty"`
Warning string `json:"warning,omitempty"`
State string `json:"state,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Warning string `json:"warning,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
6 changes: 5 additions & 1 deletion apis/status/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ spec:
vapGenerationStatus:
description: VAPGenerationStatus represents the status of VAP generation.
properties:
observedGeneration:
format: int64
type: integer
state:
type: string
warning:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
vapGenerationStatus:
description: VAPGenerationStatus represents the status of VAP generation.
properties:
observedGeneration:
format: int64
type: integer
state:
type: string
warning:
Expand Down
3 changes: 3 additions & 0 deletions manifest_staging/deploy/gatekeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,9 @@ spec:
vapGenerationStatus:
description: VAPGenerationStatus represents the status of VAP generation.
properties:
observedGeneration:
format: int64
type: integer
state:
type: string
warning:
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/constrainttemplate/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (

const (
// ErrGenerateVAPState indicates a problem generating a VAP.
ErrGenerateVAPState = "errror"
ErrGenerateVAPState = "error"
// GeneratedVAPState indicates a VAP was generated.
GeneratedVAPState = "generated"
)
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ func (r *ReconcileConstraintTemplate) Reconcile(ctx context.Context, request rec
status.Status.TemplateUID = ct.GetUID()
status.Status.ObservedGeneration = ct.GetGeneration()
status.Status.Errors = nil
status.Status.VAPGenerationStatus = statusv1beta1.VAPGenerationStatus{}

unversionedProposedCRD, err := r.cfClient.CreateCRD(ctx, unversionedCT)
if err != nil {
Expand Down Expand Up @@ -447,6 +446,7 @@ func (r *ReconcileConstraintTemplate) handleUpdate(
if generateVap {
generateVap = false
status.Status.VAPGenerationStatus.State = ErrGenerateVAPState
status.Status.VAPGenerationStatus.ObservedGeneration = ct.GetGeneration()
status.Status.VAPGenerationStatus.Warning = fmt.Sprintf("ValidatingAdmissionPolicy is not generated: %s", err.Error())
}
}
Expand Down Expand Up @@ -858,6 +858,8 @@ func (r *ReconcileConstraintTemplate) manageVAP(ctx context.Context, ct *v1beta1
}
}
status.Status.VAPGenerationStatus.State = GeneratedVAPState
status.Status.VAPGenerationStatus.ObservedGeneration = ct.GetGeneration()
status.Status.VAPGenerationStatus.Warning = ""
}
// do not generate VAP resources
// remove if exists
Expand Down

0 comments on commit ae48233

Please sign in to comment.