-
Notifications
You must be signed in to change notification settings - Fork 0
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
Maintenance Events resource was transfered to the APIv2 #555
Conversation
7f8e3d1
to
518b189
Compare
518b189
to
2cc9c6c
Compare
2cc9c6c
to
4400f48
Compare
} | ||
|
||
// MaintenanceEventsStatus defines the observed state of MaintenanceEvents | ||
type MaintenanceEventsStatus struct { | ||
EventsStatuses []*MaintenanceEventStatus `json:"eventsStatuses,omitempty"` | ||
RescheduledEvent MaintenanceEventReschedule `json:"rescheduled"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RescheduledEvent -> CurrentRescheduledEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
type MaintenanceEventReschedule struct { | ||
ScheduledStartTime string `json:"scheduledStartTime"` | ||
MaintenanceEventId string `json:"maintenanceEventId"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MaintenanceEventId -> MaintenanceEventID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
for _, event := range r.Spec.MaintenanceEventsReschedules { | ||
if dateValid, err := validation.ValidateISODate(event.ScheduledStartTime); err != nil || !dateValid { | ||
return fmt.Errorf("scheduledStartTime must be provided in an ISO-8601 formatted UTC string: %v", err) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last part of the 79 line:
; err != nil || !dateValid
so the validation.ValidateISODate
function may not have an error, and still dateValid
variable may not be valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the customer provides scheduledStartTime
in an invalid format, we will return the error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why then check for !dateValid
, if there is always an error returned by invalid format?
apis/clusters/v1beta1/structs.go
Outdated
return true | ||
} | ||
|
||
func areClusteredMaintenanceEventStatusEqual(a, b *clusterresource.MaintenanceEventStatus) bool { | ||
return a.ID == b.ID && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a.ID == b.ID
shouldn't be used in comparing, instead, use this condition to actually be sure that this is the same maintenance event and after only perform equality func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix
apis/clusters/v1beta1/structs.go
Outdated
@@ -509,6 +542,28 @@ func (c *Cluster) CloudProviderSettingsFromInstAPI(iDC models.DataCentre) (setti | |||
return | |||
} | |||
|
|||
func (c *Cluster) CloudProviderSettingsFromInstAPIv1(iProviders []*models.ClusterProviderV1) (accountName string, settings []*CloudProviderSettings) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, it seems that I've accidentally added this method when resolving conflicts
@@ -3,7 +3,7 @@ kind: Cassandra | |||
metadata: | |||
name: cassandra-cluster | |||
spec: | |||
name: "username-Cassandra" | |||
name: "danylo-Cassandra" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave it as it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
patch := me.NewPatch() | ||
me.Status.RescheduledEvent = *meReschedule | ||
err = r.Status().Patch(ctx, me, patch) | ||
if err != nil { | ||
l.Error(err, "Cannot get Maintenance Events resource", | ||
"resource", me, | ||
l.Error(err, | ||
"Cannot patch Maintenance Event status", | ||
"Maintenance Event ID", me.Status.RescheduledEvent.MaintenanceEventId, | ||
) | ||
|
||
return err | ||
r.EventRecorder.Eventf( | ||
me, models.Warning, models.PatchFailed, | ||
"Resource status patch is failed. Reason: %v", | ||
err, | ||
) | ||
return models.ReconcileRequeue, nil | ||
} | ||
|
||
var updated bool | ||
patch := me.NewPatch() | ||
instMEventsStatuses, err := r.API.GetMaintenanceEventsStatuses(me.Spec.ClusterID) | ||
patch = me.NewPatch() | ||
me.Status.RescheduledEvent.MaintenanceEventId = "" | ||
me.Status.RescheduledEvent.ScheduledStartTime = "" | ||
err = r.Status().Patch(ctx, me, patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no point in filling out the Status and then removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid point, will fix
if !c.Status.AreMaintenanceEventStatusesEqual(iMEStatuses) { | ||
patch := c.NewPatch() | ||
c.Status.MaintenanceEvents = iMEStatuses | ||
err = r.Status().Patch(context.TODO(), c, patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use ctx from the func param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed for all similar cases
controllers/clusters/helpers.go
Outdated
"encoding/json" | ||
"fmt" | ||
clusterresourcesv1beta1 "github.com/instaclustr/operator/apis/clusterresources/v1beta1" | ||
"github.com/instaclustr/operator/pkg/instaclustr" | ||
"sort" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
busted 🐾 🐾 🐾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
controllers/clusters/helpers.go
Outdated
func fetchMaintenanceEventStatuses( | ||
api instaclustr.API, | ||
clusterID string, | ||
) ([]*clusterresourcesv1beta1.ClusteredMaintenanceEventStatus, | ||
error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making it as a method for instaclustr.API
client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds pretty logical, will move to the client
type ClusteredMaintenanceEventStatus struct { | ||
InProgress []*MaintenanceEventStatus `json:"inProgress"` | ||
Past []*MaintenanceEventStatus `json:"past"` | ||
Upcoming []*MaintenanceEventStatus `json:"Upcoming"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upcoming []*MaintenanceEventStatus `json:"Upcoming"` | |
Upcoming []*MaintenanceEventStatus `json:"upcoming"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix
if !c.Status.AreMaintenanceEventStatusesEqual(iMEStatuses) { | ||
patch := c.NewPatch() | ||
c.Status.MaintenanceEvents = iMEStatuses | ||
err = r.Status().Patch(context.TODO(), c, patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the provided ctx from the func params. Please do it in all such cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
bcce9bb
to
b3f2910
Compare
b3f2910
to
d2ec9ae
Compare
d2ec9ae
to
b42cb94
Compare
b42cb94
to
750f126
Compare
Blocked until the https://instaclustr.atlassian.net/browse/INS-25547 issue is resolved