Skip to content

Commit 9243983

Browse files
authored
Merge pull request #8 from vrushalijoshi/master
Modifying spec for shard crd and generated clientset for it
2 parents b560243 + bc5ba2a commit 9243983

12 files changed

+628
-48
lines changed

config/crd/bases/admiral.io_shards.yaml

+65-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ spec:
4141
properties:
4242
clusters:
4343
items:
44+
description: |-
45+
clusters defines list of clusters monitored by the shard
46+
This includes cluster name, locality and list of cluster identities for which resources need to be managed
4447
properties:
45-
assets:
48+
identities:
4649
items:
4750
properties:
4851
environment:
@@ -51,13 +54,74 @@ spec:
5154
type: string
5255
type: object
5356
type: array
57+
locality:
58+
type: string
5459
name:
5560
type: string
5661
type: object
5762
type: array
5863
type: object
5964
status:
6065
description: ShardStatus defines the observed state of Shard
66+
properties:
67+
clustersMonitored:
68+
type: integer
69+
conditions:
70+
items:
71+
description: |-
72+
condition defines details for status condition including type, when it was updates and reason for the update
73+
74+
75+
Possible condition type are -
76+
SyncComplete - Set to provide update on the sync state
77+
SyncFailed - Set to provide update on the sync state if failure occurred
78+
79+
80+
Possible condition reason are -
81+
stillProcessing - set when resources for the provided identities are getting processed
82+
processed - set when all the clusters and related identity resource are processes
83+
errorOccurred - set when error occurred while processing the resources, more details for which identities failed and why will be provided in failureDetails section
84+
properties:
85+
lastUpdateTime:
86+
format: date-time
87+
type: string
88+
message:
89+
type: string
90+
reason:
91+
type: string
92+
status:
93+
type: string
94+
type:
95+
type: string
96+
type: object
97+
type: array
98+
failureDetails:
99+
description: failureDetails define details of which clusters and identities
100+
observed failures while processing resources
101+
properties:
102+
clusters:
103+
items:
104+
properties:
105+
identities:
106+
items:
107+
properties:
108+
errorMessage:
109+
type: string
110+
name:
111+
type: string
112+
type: object
113+
type: array
114+
name:
115+
type: string
116+
type: object
117+
type: array
118+
lastUpdateTime:
119+
format: date-time
120+
type: string
121+
type: object
122+
lastUpdateTime:
123+
format: date-time
124+
type: string
61125
type: object
62126
type: object
63127
served: true

pkg/apis/admiral/v1/shard_types.go

+67-5
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,80 @@ type ShardSpec struct {
4646
Clusters []ClusterShards `json:"clusters,omitempty"`
4747
}
4848

49+
// clusters defines list of clusters monitored by the shard
50+
// This includes cluster name, locality and list of cluster identities for which resources need to be managed
4951
type ClusterShards struct {
50-
Name string `json:"name,omitempty"`
51-
Assets []AssetItem `json:"assets,omitempty"`
52+
Name string `json:"name,omitempty"`
53+
Locality string `json:"locality,omitempty"`
54+
Identities []IdentityItem `json:"identities,omitempty"`
5255
}
5356

54-
type AssetItem struct {
57+
type IdentityItem struct {
5558
Name string `json:"name,omitempty"`
5659
Environment string `json:"environment,omitempty"`
5760
}
5861

5962
// ShardStatus defines the observed state of Shard
6063
type ShardStatus struct {
61-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
62-
// Important: Run "make" to regenerate code after modifying this file
64+
ClustersMonitored int `json:"clustersMonitored,omitempty"`
65+
Conditions []ShardStatusCondition `json:"conditions,omitempty"`
66+
FailureDetails FailureDetails `json:"failureDetails,omitempty"`
67+
LastUpdatedTime metav1.Time `json:"lastUpdateTime,omitempty"`
68+
}
69+
70+
type ConditionStatus string
71+
72+
const (
73+
TrueConditionStatus ConditionStatus = "true"
74+
FalseConditionStatus ConditionStatus = "false"
75+
)
76+
77+
type ConditionType string
78+
79+
const (
80+
SyncComplete ConditionType = "SyncComplete"
81+
SyncFailed ConditionType = "SyncFailed"
82+
)
83+
84+
type ConditionReason string
85+
86+
const (
87+
Processing ConditionReason = "stillProcessing"
88+
Processed ConditionReason = "processed"
89+
ErrorOccurred ConditionReason = "errorOccurred"
90+
)
91+
92+
/* condition defines details for status condition including type, when it was updates and reason for the update
93+
94+
Possible condition type are -
95+
SyncComplete - Set to provide update on the sync state
96+
SyncFailed - Set to provide update on the sync state if failure occurred
97+
98+
Possible condition reason are -
99+
stillProcessing - set when resources for the provided identities are getting processed
100+
processed - set when all the clusters and related identity resource are processes
101+
errorOccurred - set when error occurred while processing the resources, more details for which identities failed and why will be provided in failureDetails section
102+
*/
103+
type ShardStatusCondition struct {
104+
Message string `json:"message,omitempty"`
105+
Reason ConditionReason `json:"reason,omitempty"`
106+
Status ConditionStatus `json:"status,omitempty"`
107+
Type ConditionType `json:"type,omitempty"`
108+
LastUpdatedTime metav1.Time `json:"lastUpdateTime,omitempty"`
109+
}
110+
111+
// failureDetails define details of which clusters and identities observed failures while processing resources
112+
type FailureDetails struct {
113+
LastUpdatedTime metav1.Time `json:"lastUpdateTime,omitempty"`
114+
FailedClusters []FailedCluster `json:"clusters,omitempty"`
115+
}
116+
117+
type FailedCluster struct {
118+
Name string `json:"name,omitempty"`
119+
FailedIdentities []FailedIdentity `json:"identities,omitempty"`
120+
}
121+
122+
type FailedIdentity struct {
123+
Name string `json:"name,omitempty"`
124+
Message string `json:"errorMessage,omitempty"`
63125
}

0 commit comments

Comments
 (0)