Skip to content

Commit d482e42

Browse files
[Feature] [ML] Extension STS update propagation (#1548)
1 parent 7dbd3ad commit d482e42

File tree

12 files changed

+149
-30
lines changed

12 files changed

+149
-30
lines changed

docs/api/ArangoMLExtension.V1Alpha1.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,18 @@ UID keeps the information about object UID
14271427

14281428
***
14291429

1430+
### .status.reconciliation.serviceChecksum
1431+
1432+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_status_reconciliation.go#L25)</sup>
1433+
1434+
***
1435+
1436+
### .status.reconciliation.statefulSetChecksum
1437+
1438+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_status_reconciliation.go#L24)</sup>
1439+
1440+
***
1441+
14301442
### .status.serviceAccount.cluster.binding.name
14311443

14321444
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L46)</sup>

pkg/apis/deployment/v1/plan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ type Action struct {
8282
MemberID string `json:"memberID,omitempty"`
8383
// Group involved in this action
8484
Group ServerGroup `json:"group,omitempty"`
85-
// CreationTime is set the when the action is created.
85+
// CreationTime is set when the action is created.
8686
CreationTime meta.Time `json:"creationTime"`
87-
// StartTime is set the when the action has been started, but needs to wait to be finished.
87+
// StartTime is set when the action has been started, but needs to wait to be finished.
8888
StartTime *meta.Time `json:"startTime,omitempty"`
8989
// Reason for this action
9090
Reason string `json:"reason,omitempty"`
@@ -98,7 +98,7 @@ type Action struct {
9898
TaskID types.UID `json:"taskID,omitempty"`
9999
// Architecture of the member involved in this action (if any)
100100
Architecture ArangoDeploymentArchitectureType `json:"arch,omitempty"`
101-
// Progress describes what is a status of the current action.
101+
// Progress describes the status of the current action.
102102
Progress string `json:"progress,omitempty"`
103103
}
104104

pkg/apis/deployment/v2alpha1/plan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ type Action struct {
8282
MemberID string `json:"memberID,omitempty"`
8383
// Group involved in this action
8484
Group ServerGroup `json:"group,omitempty"`
85-
// CreationTime is set the when the action is created.
85+
// CreationTime is set when the action is created.
8686
CreationTime meta.Time `json:"creationTime"`
87-
// StartTime is set the when the action has been started, but needs to wait to be finished.
87+
// StartTime is set when the action has been started, but needs to wait to be finished.
8888
StartTime *meta.Time `json:"startTime,omitempty"`
8989
// Reason for this action
9090
Reason string `json:"reason,omitempty"`
@@ -98,7 +98,7 @@ type Action struct {
9898
TaskID types.UID `json:"taskID,omitempty"`
9999
// Architecture of the member involved in this action (if any)
100100
Architecture ArangoDeploymentArchitectureType `json:"arch,omitempty"`
101-
// Progress describes what is a status of the current action.
101+
// Progress describes the status of the current action.
102102
Progress string `json:"progress,omitempty"`
103103
}
104104

pkg/apis/ml/v1alpha1/extension_spec_deployment.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
165165
continue
166166
}
167167

168-
if usedPorts.IndexOf(port) >= 0 {
168+
duplicateCount := usedPorts.Count(func(i int32) bool {
169+
return i == port
170+
})
171+
if duplicateCount > 0 {
169172
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port %d already specified for other component", port)))
170173
} else {
171174
usedPorts.Append(port)

pkg/apis/ml/v1alpha1/extension_status.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ type ArangoMLExtensionStatus struct {
3838

3939
// ArangoDB keeps the information about local arangodb reference
4040
ArangoDB *ArangoMLExtensionStatusArangoDBRef `json:"arangoDB,omitempty"`
41+
42+
// Reconciliation keeps the information about reconciliation process. For internal use.
43+
Reconciliation *ArangoMLExtensionStatusReconciliation `json:"reconciliation"`
4144
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
type ArangoMLExtensionStatusReconciliation struct {
24+
StatefulSetChecksum string `json:"statefulSetChecksum,omitempty"`
25+
ServiceChecksum string `json:"serviceChecksum,omitempty"`
26+
}
27+
28+
func (r *ArangoMLExtensionStatusReconciliation) GetStatefulSetChecksum() string {
29+
if r == nil {
30+
return ""
31+
}
32+
return r.StatefulSetChecksum
33+
}
34+
35+
func (r *ArangoMLExtensionStatusReconciliation) GetServiceChecksum() string {
36+
if r == nil {
37+
return ""
38+
}
39+
return r.ServiceChecksum
40+
}

pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/util/compare/compare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func P2[T interface{}, P1, P2 interface{}](
123123
}
124124

125125
if m, p, err := Evaluate(actionBuilder, evaluatorsFunc...); err != nil {
126-
log.Err(err).Error("Error while getting diff")
126+
log.Err(err).Error("Error while running evaluators")
127127
return SkippedRotation, nil, err
128128
} else {
129129
mode = mode.And(m)

pkg/util/compare/interfaces.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ import (
2626

2727
type Template[T interface{}] interface {
2828
GetTemplate() *T
29-
SetTemplate(*T)
30-
31-
GetTemplateChecksum() string
32-
SetTemplateChecksum(string)
33-
3429
GetChecksum() string
35-
SetChecksum(string)
3630
}
3731

3832
type Checksum[T interface{}] func(in *T) (string, error)

pkg/util/helpers.go renamed to pkg/util/compare/k8s/service.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,24 @@
1818
// Copyright holder is ArangoDB GmbH, Cologne, Germany
1919
//
2020

21-
package util
21+
package k8s
2222

23-
// Ter implements a ternary operation: return cond ? a : b;
24-
func Ter[T any](cond bool, a T, b T) T {
25-
if cond {
26-
return a
23+
import (
24+
core "k8s.io/api/core/v1"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util"
27+
)
28+
29+
func ChecksumService(s *core.Service) (string, error) {
30+
return checksumServiceSpec(&s.Spec)
31+
}
32+
33+
func checksumServiceSpec(s *core.ServiceSpec) (string, error) {
34+
parts := map[string]interface{}{
35+
"type": s.Type,
36+
"ports": s.Ports,
37+
"selector": s.Selector,
38+
// add here more fields when needed
2739
}
28-
return b
40+
return util.SHA256FromJSON(parts)
2941
}

0 commit comments

Comments
 (0)