-
Notifications
You must be signed in to change notification settings - Fork 113
/
wait_for_cluster_domain.go
56 lines (45 loc) · 1.91 KB
/
wait_for_cluster_domain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package provisioning
import (
"context"
"time"
gardener_types "github.com/gardener/gardener/pkg/apis/core/v1beta1"
"github.com/sirupsen/logrus"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kyma-project/control-plane/components/provisioner/internal/apperrors"
"github.com/kyma-project/control-plane/components/provisioner/internal/model"
"github.com/kyma-project/control-plane/components/provisioner/internal/operations"
"github.com/kyma-project/control-plane/components/provisioner/internal/util"
)
type WaitForClusterDomainStep struct {
gardenerClient GardenerClient
nextStep model.OperationStage
timeLimit time.Duration
}
//go:generate mockery --name=GardenerClient
type GardenerClient interface {
Get(ctx context.Context, name string, options v1.GetOptions) (*gardener_types.Shoot, error)
}
func NewWaitForClusterDomainStep(gardenerClient GardenerClient, nextStep model.OperationStage, timeLimit time.Duration) *WaitForClusterDomainStep {
return &WaitForClusterDomainStep{
gardenerClient: gardenerClient,
nextStep: nextStep,
timeLimit: timeLimit,
}
}
func (s *WaitForClusterDomainStep) Name() model.OperationStage {
return model.WaitingForClusterDomain
}
func (s *WaitForClusterDomainStep) TimeLimit() time.Duration {
return s.timeLimit
}
func (s *WaitForClusterDomainStep) Run(cluster model.Cluster, _ model.Operation, log logrus.FieldLogger) (operations.StageResult, error) {
shoot, err := s.gardenerClient.Get(context.Background(), cluster.ClusterConfig.Name, v1.GetOptions{})
if err != nil {
return operations.StageResult{}, util.K8SErrorToAppError(err).SetComponent(apperrors.ErrGardenerClient)
}
if shoot.Spec.DNS == nil || shoot.Spec.DNS.Domain == nil {
log.Warnf("DNS Domain is not set yet for runtime ID: %s", cluster.ID)
return operations.StageResult{Stage: s.Name(), Delay: 5 * time.Second}, nil
}
return operations.StageResult{Stage: s.nextStep, Delay: 0}, nil
}