Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated library deps #157

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-go@v3
name: Set up Go 1.x
with:
go-version: 1.19
go-version: "1.20"

- uses: actions/checkout@v3
name: Checkout frontend-operator
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2
name: Set up golang 1.19
name: Set up golang 1.20
with:
go-version: '1.19.10'
go-version: '1.20'
- name: Check out source code
uses: actions/checkout@v2
- name: Install package and dependencies
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.19.13-2.1698062273 as base
FROM registry.access.redhat.com/ubi8/go-toolset:1.20.12-5 as base

WORKDIR /workspace

Expand Down Expand Up @@ -41,7 +41,7 @@ COPY controllers/ controllers/
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o manager main.go

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8-1072.1697626218
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9-1161
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65534:65534
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23
ENVTEST_K8S_VERSION = 1.28

# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
Expand Down Expand Up @@ -105,7 +105,7 @@ vet: ## Run go vet against code.

ENVTEST = $(shell pwd)/testbin/bin/setup-envtest
envtest: ## Download envtest-setup locally if necessary.
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@d0396a3d6f9fb554ef2da382a3d0bf05f7565e65)

test: manifests envtest generate fmt vet
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
Expand Down
17 changes: 8 additions & 9 deletions api/v1alpha1/frontend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -60,15 +59,15 @@ type FrontendSpec struct {
AkamaiCacheBustPaths []string `json:"akamaiCacheBustPaths,omitempty" yaml:"akamaiCacheBustPaths,omitempty"`
}

var ReconciliationSuccessful clusterv1.ConditionType = "ReconciliationSuccessful"
var ReconciliationFailed clusterv1.ConditionType = "ReconciliationFailed"
var FrontendsReady clusterv1.ConditionType = "FrontendsReady"
var ReconciliationSuccessful = "ReconciliationSuccessful"
var ReconciliationFailed = "ReconciliationFailed"
var FrontendsReady = "FrontendsReady"

// FrontendStatus defines the observed state of Frontend
type FrontendStatus struct {
Deployments FrontendDeployments `json:"deployments,omitempty"`
Ready bool `json:"ready"`
Conditions []clusterv1.Condition `json:"conditions,omitempty"`
Deployments FrontendDeployments `json:"deployments,omitempty"`
Ready bool `json:"ready"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

type FrontendDeployments struct {
Expand Down Expand Up @@ -125,11 +124,11 @@ type FrontendList struct {
Items []Frontend `json:"items" yaml:"items"`
}

func (i *Frontend) GetConditions() clusterv1.Conditions {
func (i *Frontend) GetConditions() []metav1.Condition {
return i.Status.Conditions
}

func (i *Frontend) SetConditions(conditions clusterv1.Conditions) {
func (i *Frontend) SetConditions(conditions []metav1.Condition) {
i.Status.Conditions = conditions
}

Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 46 additions & 22 deletions config/crd/bases/cloud.redhat.com_frontends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,44 +264,68 @@ spec:
properties:
conditions:
items:
description: Condition defines an observation of a Cluster API resource
operational state.
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status of the condition, one of True, False, Unknown.
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down
18 changes: 11 additions & 7 deletions controllers/frontend_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

crd "github.com/RedHatInsights/frontend-operator/api/v1alpha1"
"github.com/onsi/ginkgo"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
prom "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
apps "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -346,20 +346,24 @@ var _ = ginkgo.Describe("Frontend controller with service", func() {
}))

gomega.Eventually(func() bool {
fmt.Printf("TESTING..............")
nfe := &crd.Frontend{}
err := k8sClient.Get(ctx, types.NamespacedName{Name: frontend.Name, Namespace: frontend.Namespace}, nfe)
if err != nil {
fmt.Printf("ERRRRORRRRR: %s", err)
return false
}

fmt.Printf("SO GO HERE.....")
fmt.Printf("%v", nfe.Status.Conditions)
// Check the length of Conditions slice before accessing by index
if len(nfe.Status.Conditions) > 2 {
gomega.Expect(nfe.Status.Conditions[0].Type).Should(gomega.Equal(crd.FrontendsReady))
gomega.Expect(nfe.Status.Conditions[0].Status).Should(gomega.Equal(v1.ConditionTrue))
fmt.Printf("I GOT TRUE???")
gomega.Expect(nfe.Status.Conditions[0].Type).Should(gomega.Equal(crd.ReconciliationSuccessful))
gomega.Expect(nfe.Status.Conditions[0].Status).Should(gomega.Equal(metav1.ConditionTrue))
gomega.Expect(nfe.Status.Conditions[1].Type).Should(gomega.Equal(crd.ReconciliationFailed))
gomega.Expect(nfe.Status.Conditions[1].Status).Should(gomega.Equal(v1.ConditionFalse))
gomega.Expect(nfe.Status.Conditions[2].Type).Should(gomega.Equal(crd.ReconciliationSuccessful))
gomega.Expect(nfe.Status.Conditions[2].Status).Should(gomega.Equal(v1.ConditionTrue))
gomega.Expect(nfe.Status.Conditions[1].Status).Should(gomega.Equal(metav1.ConditionFalse))
gomega.Expect(nfe.Status.Conditions[2].Type).Should(gomega.Equal(crd.FrontendsReady))
gomega.Expect(nfe.Status.Conditions[2].Status).Should(gomega.Equal(metav1.ConditionTrue))
gomega.Expect(nfe.Status.Ready).Should(gomega.Equal(true))
return true
}
Expand Down
38 changes: 20 additions & 18 deletions controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ import (
crd "github.com/RedHatInsights/frontend-operator/api/v1alpha1"
"github.com/RedHatInsights/rhc-osdk-utils/resources"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
cond "sigs.k8s.io/cluster-api/util/conditions"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func SetFrontendConditions(ctx context.Context, client client.Client, o *crd.Frontend, state clusterv1.ConditionType, err error) error {
func SetFrontendConditions(ctx context.Context, client client.Client, o *crd.Frontend, state string, err error) error {
oldStatus := o.Status.DeepCopy()
conditions := []clusterv1.Condition{}
conditions := []metav1.Condition{}

loopConditions := []clusterv1.ConditionType{crd.ReconciliationSuccessful, crd.ReconciliationFailed}
loopConditions := []string{crd.ReconciliationSuccessful, crd.ReconciliationFailed}
for _, conditionType := range loopConditions {
condition := &clusterv1.Condition{}
condition := &metav1.Condition{}
condition.Type = conditionType
condition.Status = core.ConditionFalse
condition.Status = metav1.ConditionFalse
condition.Reason = "NoError"

if state == conditionType {
condition.Status = core.ConditionTrue
condition.Status = metav1.ConditionTrue
if err != nil {
condition.Reason = err.Error()
condition.Message = err.Error()
condition.Reason = "Error"
}
}

condition.LastTransitionTime = v1.Now()
condition.LastTransitionTime = metav1.Now()
conditions = append(conditions, *condition)
}

Expand All @@ -41,25 +41,27 @@ func SetFrontendConditions(ctx context.Context, client client.Client, o *crd.Fro
return err
}

condition := &clusterv1.Condition{}
condition := &metav1.Condition{}

condition.Status = core.ConditionFalse
condition.Reason = "NoError"
condition.Status = metav1.ConditionFalse
condition.Message = "Deployments are not yet ready"
if frontendStatus {
condition.Status = core.ConditionTrue
condition.Status = metav1.ConditionTrue
condition.Message = "All managed deployments ready"
}

condition.Type = crd.FrontendsReady
condition.LastTransitionTime = v1.Now()
condition.LastTransitionTime = metav1.Now()
if err != nil {
condition.Reason = err.Error()
condition.Message += err.Error()
condition.Reason = "Error"
}

conditions = append(conditions, *condition)
for _, condition := range conditions {
innerCondition := condition
cond.Set(o, &innerCondition)
meta.SetStatusCondition(&o.Status.Conditions, innerCondition)
}

o.Status.Ready = frontendStatus
Expand Down
7 changes: 4 additions & 3 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"
"path/filepath"
"testing"
"time"

"github.com/onsi/ginkgo"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
prom "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -39,7 +40,7 @@ func TestAPIs(t *testing.T) {
ginkgo.RunSpecs(t, "Controller Suite")
}

var _ = ginkgo.BeforeSuite(func() {
var _ = ginkgo.BeforeSuite(func(_ context.Context) {
logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true)))
k8sscheme := runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(k8sscheme))
Expand Down Expand Up @@ -98,7 +99,7 @@ var _ = ginkgo.BeforeSuite(func() {
gomega.Expect(err).ToNot(gomega.HaveOccurred())
}()

}, 60)
}, ginkgo.NodeTimeout(time.Second*60))

var _ = ginkgo.AfterSuite(func() {
ginkgo.By("tearing down the test environment")
Expand Down
Loading
Loading