-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
349 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package constants | ||
|
||
var ( | ||
CreateTreeDeadline int64 = 1200 | ||
CreateTreeDeadline int64 = 30 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package actions | ||
|
||
import ( | ||
"context" | ||
|
||
rhtasv1alpha1 "github.com/securesign/operator/api/v1alpha1" | ||
"github.com/securesign/operator/internal/controller/common/action" | ||
"github.com/securesign/operator/internal/controller/constants" | ||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func NewHandleErrorAction() action.Action[rhtasv1alpha1.Rekor] { | ||
return &handleErrorAction{} | ||
} | ||
|
||
type handleErrorAction struct { | ||
action.BaseAction | ||
} | ||
|
||
func (i handleErrorAction) Name() string { | ||
return "error handler" | ||
} | ||
|
||
func (i handleErrorAction) CanHandle(_ context.Context, instance *rhtasv1alpha1.Rekor) bool { | ||
c := meta.FindStatusCondition(instance.Status.Conditions, constants.Ready) | ||
if c == nil { | ||
return false | ||
} | ||
return c.Reason == constants.Failure | ||
} | ||
|
||
func (i handleErrorAction) Handle(ctx context.Context, instance *rhtasv1alpha1.Rekor) *action.Result { | ||
i.Recorder.Event(instance, v1.EventTypeWarning, constants.Failure, "Restarted by error handler") | ||
|
||
newStatus := rhtasv1alpha1.RekorStatus{} | ||
|
||
// - keep the status.treeId if not nil | ||
newStatus.TreeID = instance.Status.TreeID | ||
// - keep the status.pvcName if not nil | ||
newStatus.PvcName = instance.Status.PvcName | ||
|
||
if meta.IsStatusConditionTrue(instance.Status.Conditions, SignerCondition) { | ||
instance.Status.Signer.DeepCopyInto(&newStatus.Signer) | ||
newStatus.Conditions = append(newStatus.Conditions, *meta.FindStatusCondition(instance.Status.Conditions, SignerCondition)) | ||
} | ||
|
||
if meta.IsStatusConditionTrue(instance.Status.Conditions, ServerCondition) { | ||
instance.Status.ServerConfigRef.DeepCopyInto(newStatus.ServerConfigRef) | ||
// do not append server condition - let controller to redeploy | ||
} | ||
|
||
meta.SetStatusCondition(&newStatus.Conditions, metav1.Condition{ | ||
Type: constants.Ready, | ||
Status: metav1.ConditionFalse, | ||
Reason: constants.Pending, | ||
Message: "Restarted by error handler", | ||
}) | ||
instance.Status = newStatus | ||
return i.StatusUpdate(ctx, instance) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
internal/controller/rekor/actions/transitions/to_create_phase.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package transitions | ||
|
||
import ( | ||
"context" | ||
|
||
rhtasv1alpha1 "github.com/securesign/operator/api/v1alpha1" | ||
"github.com/securesign/operator/internal/controller/common/action" | ||
"github.com/securesign/operator/internal/controller/constants" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func NewToCreateAction() action.Action[rhtasv1alpha1.Rekor] { | ||
return &toCreateAction{} | ||
} | ||
|
||
type toCreateAction struct { | ||
action.BaseAction | ||
} | ||
|
||
func (i toCreateAction) Name() string { | ||
return "move to create phase" | ||
} | ||
|
||
func (i toCreateAction) CanHandle(_ context.Context, instance *rhtasv1alpha1.Rekor) bool { | ||
c := meta.FindStatusCondition(instance.Status.Conditions, constants.Ready) | ||
if c == nil { | ||
return false | ||
} | ||
return c.Reason == constants.Pending | ||
} | ||
|
||
func (i toCreateAction) Handle(ctx context.Context, instance *rhtasv1alpha1.Rekor) *action.Result { | ||
|
||
meta.SetStatusCondition(&instance.Status.Conditions, metav1.Condition{Type: constants.Ready, | ||
Status: metav1.ConditionFalse, Reason: constants.Creating}) | ||
|
||
return i.StatusUpdate(ctx, instance) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.