Skip to content

🌱 Force Cache Refresh when Server was not found by name.#84

Merged
guettli merged 17 commits intomainfrom
tg/refresh-stale-cache
Mar 19, 2026
Merged

🌱 Force Cache Refresh when Server was not found by name.#84
guettli merged 17 commits intomainfrom
tg/refresh-stale-cache

Conversation

@guettli
Copy link

@guettli guettli commented Mar 16, 2026

Refresh the Robot server cache once when a bare-metal node lookup by name misses in the cached list.

This fixes the case where:

  1. the cache is filled,
  2. a new bare-metal server is created,
  3. InstanceExists() looks up the server by name,
  4. the cached list is stale and would otherwise return false.

Changes

  • add ServerGetListForceRefresh() to the Robot client interface
  • implement forced cache reload in the cached Robot client
  • make getRobotServerByName() retry once with a forced refresh after a cache miss
  • add a regression test covering:
    • cache filled with bm-existing
    • bm-new created afterwards
    • InstanceExists(bm-new) must return true

@guettli guettli force-pushed the tg/refresh-stale-cache branch from 9a905a4 to a8f2d65 Compare March 16, 2026 15:34
@guettli guettli force-pushed the tg/refresh-stale-cache branch from 5679a23 to 02bd962 Compare March 16, 2026 15:47
@guettli guettli force-pushed the tg/refresh-stale-cache branch from 02bd962 to 1d9d7da Compare March 16, 2026 15:47
guettli added 4 commits March 17, 2026 09:42
	// Remember this node name, so that it does not trigger a cache refresh again.
	c.NodeTriggeredForcedRefresh(string(node.Name))
@guettli guettli requested a review from janiskemper March 17, 2026 09:04
}
}

func TestInstances_InstanceExistsRobotServerRepeatedMissingNameSkipsForceRefresh(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this comment:

	// If a node name is not in the cache, then only on the time the cache should be refreshed. A
	// second time (during the time of CACHE_TIMEOUT), the unknown node name should not trigger a
	// cache refresh again.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just check twice the same thing. How does that fit to the description? I still don't understand it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janiskemper I updated the test and added coments: 4cfba46

return c.ServerGetList()
}

c.m = nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment that you do this in order to delete the cache and to call the actual API?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of 57538d0


// nodeTriggeredForcedRefresh records that nodeName already triggered a forced
// refresh.
func (c *cacheRobotClient) nodeTriggeredForcedRefresh(nodeName string) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you inline this function? I find it confusing that it is not. AFAIK it's only used in one place.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of 57538d0

@guettli guettli requested a review from janiskemper March 19, 2026 07:57
@guettli guettli merged commit 12329f5 into main Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants