Skip to content

Commit 52e58b8

Browse files
committed
MGMT-22939: Fix cache key to get mustgather image
1 parent 31527fa commit 52e58b8

185 files changed

Lines changed: 770 additions & 34570 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ run-db-container:
557557
run-unit-test:
558558
SKIP_UT_DB=1 $(MAKE) _unit_test TIMEOUT=30m TEST="$(or $(TEST),$(shell go list ./... | grep -v subsystem))"
559559

560+
run-unit-test-api:
561+
cd api/ && go test ./...
562+
560563
ci-unit-test:
561564
./hack/start_db.sh
562565
$(MAKE) run-unit-test

api/go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
github.com/thoas/go-funk v0.9.2
1515
k8s.io/api v0.29.5
1616
k8s.io/apimachinery v0.29.5
17-
k8s.io/client-go v0.29.2
1817
sigs.k8s.io/controller-runtime v0.13.1
1918
sigs.k8s.io/yaml v1.4.0
2019
)
@@ -28,7 +27,6 @@ require (
2827
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
2928
github.com/fsnotify/fsnotify v1.7.0 // indirect
3029
github.com/go-logr/logr v1.4.3 // indirect
31-
github.com/go-logr/zapr v1.3.0 // indirect
3230
github.com/go-openapi/analysis v0.21.4 // indirect
3331
github.com/go-openapi/errors v0.20.4 // indirect
3432
github.com/go-openapi/jsonpointer v0.20.0 // indirect
@@ -70,8 +68,6 @@ require (
7068
github.com/prometheus/procfs v0.12.0 // indirect
7169
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
7270
go.mongodb.org/mongo-driver v1.12.0 // indirect
73-
go.uber.org/multierr v1.11.0 // indirect
74-
go.uber.org/zap v1.26.0 // indirect
7571
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
7672
golang.org/x/net v0.23.0 // indirect
7773
golang.org/x/oauth2 v0.12.0 // indirect
@@ -88,6 +84,7 @@ require (
8884
gopkg.in/yaml.v3 v3.0.1 // indirect
8985
gorm.io/gorm v1.24.5 // indirect
9086
k8s.io/apiextensions-apiserver v0.29.2 // indirect
87+
k8s.io/client-go v0.29.2 // indirect
9188
k8s.io/component-base v0.29.2 // indirect
9289
k8s.io/klog/v2 v2.110.1 // indirect
9390
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect

api/v1beta1/agent_webhook_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
21+
2022
. "github.com/onsi/ginkgo"
2123
. "github.com/onsi/gomega"
2224
"github.com/openshift/assisted-service/models"
@@ -48,7 +50,7 @@ var _ = Describe("ValidateUpdate", func() {
4850
Name: "new-cluster-deployment",
4951
Namespace: namespace,
5052
}
51-
warns, err := newAgent.ValidateUpdate(oldAgent)
53+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
5254
Expect(warns).To(BeNil())
5355
Expect(err).NotTo(BeNil())
5456
})
@@ -62,7 +64,7 @@ var _ = Describe("ValidateUpdate", func() {
6264
Name: "new-cluster-deployment",
6365
Namespace: namespace,
6466
}
65-
warns, err := newAgent.ValidateUpdate(oldAgent)
67+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
6668
Expect(warns).To(BeNil())
6769
Expect(err).To(BeNil())
6870
})
@@ -77,14 +79,14 @@ var _ = Describe("ValidateUpdate", func() {
7779
Name: "new-cluster-deployment",
7880
Namespace: namespace,
7981
}
80-
warns, err := newAgent.ValidateUpdate(oldAgent)
82+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
8183
Expect(warns).To(BeNil())
8284
Expect(err).To(BeNil())
8385
})
8486

8587
It("succeeds if Agent's ClusterReference is nil and remains the same", func() {
8688
newAgent := oldAgent.DeepCopy()
87-
warns, err := newAgent.ValidateUpdate(oldAgent)
89+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
8890
Expect(warns).To(BeNil())
8991
Expect(err).To(BeNil())
9092
})
@@ -95,7 +97,7 @@ var _ = Describe("ValidateUpdate", func() {
9597
Namespace: namespace,
9698
}
9799
newAgent := oldAgent.DeepCopy()
98-
warns, err := newAgent.ValidateUpdate(oldAgent)
100+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
99101
Expect(warns).To(BeNil())
100102
Expect(err).To(BeNil())
101103
})
@@ -106,7 +108,7 @@ var _ = Describe("ValidateUpdate", func() {
106108
}
107109
oldAgent.Status = AgentStatus{DebugInfo: DebugInfo{State: models.HostStatusInstalling}}
108110
newAgent := oldAgent.DeepCopy()
109-
warns, err := newAgent.ValidateUpdate(oldAgent)
111+
warns, err := newAgent.ValidateUpdate(context.TODO(), oldAgent, newAgent)
110112
Expect(warns).To(BeNil())
111113
Expect(err).To(BeNil())
112114
})

api/v1beta1/agentclassification_webhook_test.go

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
21+
2022
. "github.com/onsi/ginkgo"
2123
. "github.com/onsi/gomega"
2224
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -51,55 +53,55 @@ var _ = Describe("ValidateCreate", func() {
5153
agentClassification.Spec.LabelKey = invalidKey
5254
agentClassification.Spec.LabelValue = validValue
5355
agentClassification.Spec.Query = validQuery
54-
warn, err := agentClassification.ValidateCreate()
56+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
5557
Expect(warn).To(BeNil())
5658
Expect(err).NotTo(BeNil())
5759
})
5860
It("fails if label key has a prefix", func() {
5961
agentClassification.Spec.LabelKey = keyWithPrefix
6062
agentClassification.Spec.LabelValue = validValue
6163
agentClassification.Spec.Query = validQuery
62-
warn, err := agentClassification.ValidateCreate()
64+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
6365
Expect(warn).To(BeNil())
6466
Expect(err).NotTo(BeNil())
6567
})
6668
It("fails if label value is invalid", func() {
6769
agentClassification.Spec.LabelKey = validKey
6870
agentClassification.Spec.LabelValue = invalidValue
6971
agentClassification.Spec.Query = validQuery
70-
warn, err := agentClassification.ValidateCreate()
72+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
7173
Expect(warn).To(BeNil())
7274
Expect(err).NotTo(BeNil())
7375
})
7476
It("fails if label value starts with QUERYERROR", func() {
7577
agentClassification.Spec.LabelKey = validKey
7678
agentClassification.Spec.LabelValue = "QUERYERROR-foo"
7779
agentClassification.Spec.Query = validQuery
78-
warn, err := agentClassification.ValidateCreate()
80+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
7981
Expect(warn).To(BeNil())
8082
Expect(err).NotTo(BeNil())
8183
})
8284
It("fails if label query is invalid", func() {
8385
agentClassification.Spec.LabelKey = validKey
8486
agentClassification.Spec.LabelValue = validValue
8587
agentClassification.Spec.Query = invalidQuery
86-
warn, err := agentClassification.ValidateCreate()
88+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
8789
Expect(warn).To(BeNil())
8890
Expect(err).NotTo(BeNil())
8991
})
9092
It("fails if everything is invalid", func() {
9193
agentClassification.Spec.LabelKey = invalidKey
9294
agentClassification.Spec.LabelValue = invalidValue
9395
agentClassification.Spec.Query = invalidQuery
94-
warn, err := agentClassification.ValidateCreate()
96+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
9597
Expect(warn).To(BeNil())
9698
Expect(err).NotTo(BeNil())
9799
})
98100
It("succeeds if everything is valid", func() {
99101
agentClassification.Spec.LabelKey = validKey
100102
agentClassification.Spec.LabelValue = validValue
101103
agentClassification.Spec.Query = validQuery
102-
warn, err := agentClassification.ValidateCreate()
104+
warn, err := agentClassification.ValidateCreate(context.TODO(), agentClassification)
103105
Expect(warn).To(BeNil())
104106
Expect(err).To(BeNil())
105107
})
@@ -127,7 +129,7 @@ var _ = Describe("ValidateUpdate", func() {
127129
oldAgentClassification.Spec.Query = validQuery
128130
newAgentClassification := oldAgentClassification.DeepCopy()
129131
newAgentClassification.Spec.LabelKey = "newKey"
130-
warn, err := newAgentClassification.ValidateUpdate(oldAgentClassification)
132+
warn, err := newAgentClassification.ValidateUpdate(context.TODO(), oldAgentClassification, newAgentClassification)
131133
Expect(warn).To(BeNil())
132134
Expect(err).NotTo(BeNil())
133135
})
@@ -137,17 +139,7 @@ var _ = Describe("ValidateUpdate", func() {
137139
oldAgentClassification.Spec.Query = validQuery
138140
newAgentClassification := oldAgentClassification.DeepCopy()
139141
newAgentClassification.Spec.LabelValue = "newvalue"
140-
warn, err := newAgentClassification.ValidateUpdate(oldAgentClassification)
141-
Expect(warn).To(BeNil())
142-
Expect(err).NotTo(BeNil())
143-
})
144-
It("fails if label query is changed", func() {
145-
oldAgentClassification.Spec.LabelKey = validKey
146-
oldAgentClassification.Spec.LabelValue = validValue
147-
oldAgentClassification.Spec.Query = ".cpu.count == 2"
148-
newAgentClassification := oldAgentClassification.DeepCopy()
149-
newAgentClassification.Spec.Query = validQuery
150-
warn, err := newAgentClassification.ValidateUpdate(oldAgentClassification)
142+
warn, err := newAgentClassification.ValidateUpdate(context.TODO(), oldAgentClassification, newAgentClassification)
151143
Expect(warn).To(BeNil())
152144
Expect(err).NotTo(BeNil())
153145
})

api/v1beta1/agentserviceconfig_types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ type MustGatherImage struct {
4545
// OpenshiftVersion is the Major.Minor version of OpenShift that this image
4646
// is to be associated with.
4747
OpenshiftVersion string `json:"openshiftVersion"`
48+
// CPUArchitecture is the CPU architecture of the image (x86_64/arm64/multi/etc).
49+
// +optional
50+
CPUArchitecture string `json:"cpuArchitecture"`
4851
// Name specifies the name of the component (e.g. operator)
4952
// that the image is used to collect information about.
5053
Name string `json:"name"`
@@ -255,8 +258,8 @@ const (
255258

256259
// AgentServiceConfigStatus defines the observed state of AgentServiceConfig
257260
type AgentServiceConfigStatus struct {
258-
Conditions []conditionsv1.Condition `json:"conditions,omitempty"`
259-
ImmutableAnnotations map[string]string `json:"immutableAnnotations,omitempty"`
261+
Conditions []conditionsv1.Condition `json:"conditions,omitempty"`
262+
ImmutableAnnotations map[string]string `json:"immutableAnnotations,omitempty"`
260263
}
261264

262265
// +kubebuilder:object:root=true

api/v1beta1/infraenv_webhook_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
21+
2022
. "github.com/onsi/ginkgo"
2123
. "github.com/onsi/gomega"
2224
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -42,7 +44,7 @@ var _ = Describe("ValidateCreate", func() {
4244
Namespace: namespace,
4345
}
4446
infraEnv.Spec.OSImageVersion = "4.14"
45-
warn, err := infraEnv.ValidateCreate()
47+
warn, err := infraEnv.ValidateCreate(context.TODO(), infraEnv)
4648
Expect(warn).To(BeNil())
4749
Expect(err).NotTo(BeNil())
4850
})
@@ -53,20 +55,20 @@ var _ = Describe("ValidateCreate", func() {
5355
Namespace: namespace,
5456
}
5557

56-
warn, err := infraEnv.ValidateCreate()
58+
warn, err := infraEnv.ValidateCreate(context.TODO(), infraEnv)
5759
Expect(warn).To(BeNil())
5860
Expect(err).To(BeNil())
5961
})
6062

6163
It("succeeds if only OsImageVersion is set", func() {
6264
infraEnv.Spec.OSImageVersion = "4.14"
63-
warn, err := infraEnv.ValidateCreate()
65+
warn, err := infraEnv.ValidateCreate(context.TODO(), infraEnv)
6466
Expect(warn).To(BeNil())
6567
Expect(err).To(BeNil())
6668
})
6769

6870
It("succeeds if neither ClusterRef or OsImageVersion is set", func() {
69-
warn, err := infraEnv.ValidateCreate()
71+
warn, err := infraEnv.ValidateCreate(context.TODO(), infraEnv)
7072
Expect(warn).To(BeNil())
7173
Expect(err).To(BeNil())
7274
})
@@ -92,7 +94,7 @@ var _ = Describe("ValidateUpdate", func() {
9294
Name: "cluster-deployment",
9395
Namespace: namespace,
9496
}
95-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
97+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
9698
Expect(warn).To(BeNil())
9799
Expect(err).NotTo(BeNil())
98100
})
@@ -103,7 +105,7 @@ var _ = Describe("ValidateUpdate", func() {
103105
}
104106
newInfraEnv := oldInfraEnv.DeepCopy()
105107
newInfraEnv.Spec.ClusterRef = nil
106-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
108+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
107109
Expect(warn).To(BeNil())
108110
Expect(err).NotTo(BeNil())
109111
})
@@ -117,7 +119,7 @@ var _ = Describe("ValidateUpdate", func() {
117119
Name: "new-cluster-deployment",
118120
Namespace: namespace,
119121
}
120-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
122+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
121123
Expect(warn).To(BeNil())
122124
Expect(err).NotTo(BeNil())
123125
})
@@ -130,7 +132,7 @@ var _ = Describe("ValidateUpdate", func() {
130132
oldInfraEnv.Spec.ClusterRef = cdRef
131133
newInfraEnv := oldInfraEnv.DeepCopy()
132134
cdRef.Name = "new-cluster-deployment"
133-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
135+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
134136
Expect(warn).To(BeNil())
135137
Expect(err).NotTo(BeNil())
136138
})
@@ -143,7 +145,7 @@ var _ = Describe("ValidateUpdate", func() {
143145
oldInfraEnv.Spec.ClusterRef = cdRef
144146
newInfraEnv := oldInfraEnv.DeepCopy()
145147
cdRef.Namespace = "new-cluster-deployment-namespace"
146-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
148+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
147149
Expect(warn).To(BeNil())
148150
Expect(err).NotTo(BeNil())
149151
})
@@ -156,15 +158,15 @@ var _ = Describe("ValidateUpdate", func() {
156158
oldInfraEnv.Spec.ClusterRef = cdRef
157159
newInfraEnv := oldInfraEnv.DeepCopy()
158160
newInfraEnv.Spec.SSHAuthorizedKey = "different-ssh-key"
159-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
161+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
160162
Expect(warn).To(BeNil())
161163
Expect(err).To(BeNil())
162164
})
163165

164166
It("succeeds if ClusterRef was not set and is not changed", func() {
165167
newInfraEnv := oldInfraEnv.DeepCopy()
166168
newInfraEnv.Spec.SSHAuthorizedKey = "different-ssh-key"
167-
warn, err := newInfraEnv.ValidateUpdate(oldInfraEnv)
169+
warn, err := newInfraEnv.ValidateUpdate(context.TODO(), oldInfraEnv, newInfraEnv)
168170
Expect(warn).To(BeNil())
169171
Expect(err).To(BeNil())
170172
})

0 commit comments

Comments
 (0)