Skip to content

Commit

Permalink
Additional debug logging and minor changes to controller setup to ens…
Browse files Browse the repository at this point in the history
…ure the controllers are started before bootstraping steve components, as this seems to avoid the cache issues
  • Loading branch information
ibrokethecloud authored and starbops committed Aug 11, 2023
1 parent 7ada28c commit ef1d3fa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/harvesterhci.io/v1beta1/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const (
type AddonOperation string

var (
AddonOperationInProgress condition.Cond = "OperationInProgress"
AddonOperationCompleted condition.Cond = "OperationCompleted"
AddonOperationInProgress condition.Cond = "InProgress"
AddonOperationCompleted condition.Cond = "Completed"
AddonOperationFailed condition.Cond = "OperationFailed"
DefaultJobBackOffLimit = int32(5)
)
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/master/addon/addon_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ func (h *Handler) processEnablingAddon(a *harvesterv1.Addon) (*harvesterv1.Addon
return aObj, nil
}

logrus.Debugf("processing addon: %v", a)
if hc == nil {
// unable to find helmChart. Likely manually GC'd. Reset to initial state
// this will allow addon to be processed again and redeployed
markCompletedCondition(aObj)
aObj.Status.Status = harvesterv1.AddonDisabled
logrus.Debugf("hc not found so disabling and enabling: %v", a)
return h.addon.UpdateStatus(aObj)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/master/addon/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (h *Handler) getAddonHelmChart(aObj *harvesterv1.Addon) (*helmv1.HelmChart,
if err != nil {
// chart is gone
if apierrors.IsNotFound(err) {
logrus.Debugf("helmChart not found to addon %v", aObj.Name)
return nil, false, nil
}
return nil, false, fmt.Errorf("error querying helmchart %v", err)
Expand Down
7 changes: 6 additions & 1 deletion pkg/controller/master/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/rancher/steve/pkg/server"
"github.com/rancher/wrangler/pkg/leader"
"github.com/sirupsen/logrus"

"github.com/harvester/harvester/pkg/config"
"github.com/harvester/harvester/pkg/controller/master/addon"
Expand Down Expand Up @@ -65,15 +66,19 @@ func register(ctx context.Context, management *config.Management, options config
func Setup(ctx context.Context, server *server.Server, controllers *server.Controllers, options config.Options) error {
scaled := config.ScaledWithContext(ctx)

startupComplete := make(chan bool, 1)
go leader.RunOrDie(ctx, "", "harvester-controllers", controllers.K8s, func(ctx context.Context) {
if err := register(ctx, scaled.Management, options); err != nil {
panic(err)
}
if err := scaled.Management.Start(options.Threadiness); err != nil {
panic(err)
}
<-ctx.Done()
startupComplete <- true
})

logrus.Debug("waiting for controller boot to complete")
<-startupComplete
logrus.Debug("controller boot complete")
return nil
}

0 comments on commit ef1d3fa

Please sign in to comment.